Skip to content

Python program that surfs 3 site at a time #1389

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Oct 18, 2019
21 changes: 21 additions & 0 deletions project1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from bs4 import BeautifulSoup
import requests
#from urllib.request import urlopen
import webbrowser
import sys
from fake_useragent import UserAgent
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please explain I don't understand what to do and how to do.

Copy link
Contributor Author

@Kunal614 Kunal614 Oct 18, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't get error

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment out the line that it is complaining about and then see if the script still runs. flake8 is saying that the import is not needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment out the line that it is complaining about and then see if the script still runs. flake8 is saying that the import is not needed.

commented

ua = {"UserAgent":"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0"}
print("Googling.....")
res=requests.get('https://www.google.com/search?q='+ ' '.join(sys.argv[1:]),headers=ua)
#res.raise_for_status()
file=open('project1a.html','wb') #only for knowing the class
for i in res.iter_content(10000):
file.write(i)
soup= BeautifulSoup(res.text,'lxml')
linkele=soup.select('.eZt8xd')

num=min(5,len(linkele))
print(num)
for i in range(num):

webbrowser.open('http://google.com' + linkele[i].get('href'))