Thursday, August 13, 2020

Web Scraping data in Python with BeautifulSoup and save in file

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
import requests
from bs4 import BeautifulSoup

weburl="http://www.globegroup.in/contact/"
page = requests.get(weburl)
soup = BeautifulSoup(page.content, 'html5lib')
print(soup.prettify())

rowfile = open("rowfile.txt", "w")
rowfile.write(soup.prettify())
rowfile.close()

print("Completed")