www.xbdev.net
xbdev - software development
Wednesday March 19, 2025
Home | Contact | Support | Python Language... Power of the Snake .. ..
     
 

Python Language...

Power of the Snake .. ..

 



Python > Web Programming with Python


Python has very good support for web development with its frameworks like Django, Flask, and others.

It can be used to build server-side web applications and can be integrated with any frontend.

Generally, developers use JavaScript in frontend and python for supporting server-side operations. Python is not used directly in browsers.


Python Server


Example – Access to the computer file system from mobile
You can access your file system by running a file server on your machine. Go to the desired directory that you want to access and run the following command –

# python version >=  3.X
python3 -m http.server

# If Python version >= 2.X and < 3.X
python -m SimpleHTTPServer
#default port: 8000


This starts a file server that can be accessed on the same network. To access your files on mobile, simply connect to the same network(wifi or use the phone's hotspot on a laptop). Now in your phone browser open –

<your-computer-ip>:port


Check your IP by running – ifconfig. Check your local IP (should start with
192.168.---.---
)

Suppose your IP is –
192.168.43.155
and you use the default port. Then, you should open –

192.168.43.155:8000 on mobileYou'll see current directory 



Web Scraping


You see a lot of data every day across multiple sites. Think how cool it would be if you can access that data easily; that is what web scraping is, and python makes it even easier with its amazing support and libraries. Data on the web is unstructured, and python provides an easy way to parse and consume this data and even do further analysis and operations.

Some popular scraping libraries are:

• Beautiful Soup
• Scrapy

Let me show you an example on how you can scrape currency values from a website – x-rates.com

Example – Get currency value compared to USD


Let's use scraping in python to fetch currency values –

import requests 
from bs4 import BeautifulSoup 
  
URL "https://www.profitdata.com/table/?from=USD&amount=2"
requests.get(URL

soup BeautifulSoup(r.content'html.parser'
ratelist soup.findAll("table", {"class""ratesTable"})[0].findAll("tbody")

for 
tableVal in ratelist:
    
trList tableVal.findAll('tr')
    for 
trVal in trList[:6]:
        print(
trVal.text)

















 
Advert (Support Website)

 
 Visitor:
Copyright (c) 2002-2025 xbdev.net - All rights reserved.
Designated articles, tutorials and software are the property of their respective owners.