-
-
Notifications
You must be signed in to change notification settings - Fork 46.9k
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
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
884803a
Python program that scrufs 3 site at a time
Kunal614 dfed24a
Update project1.py
Kunal614 5c1fbea
noqa: F401 and reformat with black
cclauss 1125c44
Rename project1.py to web_programming/crawl_google_results.py
cclauss 05808a2
Add beautifulsoup4 to requirements.txt
cclauss 81106a6
Add fake_useragent to requirements.txt
cclauss 4600fea
Update crawl_google_results.py
cclauss dd627ae
headers={"UserAgent": UserAgent().random}
cclauss 1b2eb0c
html.parser, not lxml
cclauss 188d1f4
link, not links
cclauss File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
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')) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://travis-ci.com/TheAlgorithms/Python/builds/132468677#L334
There was a problem hiding this comment.
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
commented