Web Scraping in Python

Опубликовано: 04 Октябрь 2024
на канале: linuxhint
680
17

In this video, we have explained web scrapping that what web scrapping is and how we can do web scrapping using python. Web scraping is an automated way to extract and process information from internet websites in a very large amount. Data on the internet websites is not structured, which can be collected and structured through web scraping. Python is widely used for the web scrapping because it is very easy to setup and use. Python has simple syntax and built in third party libraries. We have explained the build in libraries of python that are used in web scrapping and demonstrated their installation procedure on linux. Moreover, we have demonstrated the python web scrapping with examples.
Commands used in this video for installing libraries
pip install requests
pip install html5lib
pip install bs4
pip install urllib3
Following is the code that is used in this video for demonstration
Example 1
import requests
URL = "https://linuxhint.com/"
r = requests.get(URL)
print(r.content)
Example 2
import requests
from bs4 import BeautifulSoup
URL= “https://www.fluentu.com/blog/business...
r = requests.get(URL)
soup=BeautifulSoup(r.content, ‘html5lib’)
print(soup.prettify())
Example 3
import urllib3
from bs4 import BeautifulSoup
http = urllib3.PoolManager()
r = http.request('GET', 'https://linuxhint.com')
soup = BeautifulSoup(r.data, 'html5lib')
print (soup.title)
print (soup.title.text)


#webscraping #python