added all files
This commit is contained in:
20
lib/python3.12/site-packages/main.py
Normal file
20
lib/python3.12/site-packages/main.py
Normal file
@ -0,0 +1,20 @@
|
||||
import requests
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
search_keyword = input("Enter a search keyword: ")
|
||||
|
||||
def scrape_body(url):
|
||||
response = requests.get(url)
|
||||
soup = BeautifulSoup(response.text, 'html.parser')
|
||||
body = soup.find('body')
|
||||
body_list.append(body.prettify())
|
||||
return body_list
|
||||
|
||||
if __name__ == "__main__":
|
||||
body_list = []
|
||||
for i in range(1, 11):
|
||||
search_url = 'https://www.google.com/search?q={}&start='
|
||||
scrape_body('https://www.google.com/search?q={}&start=' + str(i))
|
||||
search_url = search_url.format(search_keyword)
|
||||
with open('output.txt', 'w+') as f:
|
||||
f.writelines(body_list)
|
||||
Reference in New Issue
Block a user