-
-
Notifications
You must be signed in to change notification settings - Fork 46.2k
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
Update open_google_results.py #7085
Conversation
for more information, see https://pre-commit.ci
res = get( | ||
url, | ||
headers={ | ||
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:98.0) Gecko/20100101 Firefox/98.0" |
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.
Tests are failing on
web_programming/crawl_google_results.py:21:89: E501 line too long (106 > 88 characters)
Why is this version an improvement on the original?
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.
Why is this version an improvement on the original?
Yeah!
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.
Why is it better?
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.
Why is it better?
The previous or original one Simply type your query into Google. But this one actually scrapes the result link from Google and opens it for you. As a result, you will save time.
Running the previous or original program
C:\> python crawl_google_results.py how to code on ipad
Googling.....
3
It opens these three links, or urls, shown below:
- https://www.google.com/search?q=how+to+code+on+ipad&ie=UTF-8
- https://www.google.com/search?q=how+to+code+on+ipad&ie=UTF-8&tbm=isch
- https://www.google.com/search?q=how+to+code+on+ipad&ie=UTF-8&tbm=shop
Running my program
C:\> python crawl_google_results.py how to code on ipad
Googling.....
It opens the search result link or url.
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.
Understood. Let's move these changes to a new, separate file like launch_google_results.py
or open_google_results.py
.
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.
Yeah! sounds good
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.
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.
@cclauss So can you merge now?
from bs4 import BeautifulSoup | ||
from fake_useragent import UserAgent | ||
from requests import get |
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.
from requests import get | |
import requests |
A function called get()
is not self-documenting and may confuse the reader ("Get what from where?") so lets use requests.get()
instead.
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.
ok sure!
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.
from requests import get import requests
Changed!
Well,thank you
…------------------ 原始邮件 ------------------
发件人: "TheAlgorithms/Python" ***@***.***>;
发送时间: 2022年10月13日(星期四) 下午3:59
***@***.***>;
***@***.***>;
主题: Re: [TheAlgorithms/Python] Update crawl_google_results.py (PR #7085)
@cclauss commented on this pull request.
In web_programming/crawl_google_results.py:
> from bs4 import BeautifulSoup -from fake_useragent import UserAgent +from requests import get ⬇️ Suggested change -from requests import get +import requests
A function called get() is not self-documenting and may confuse the reader ("Get what from where?") so lets use requests.get() instead.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
@cclauss Thanks :) |
@cclauss The pre-commit on this test failed |
Yes. I clicked too quickly. I think we pre-commit fixed it on bugbear. |
Describe your change:
Created
web_programming/open_google_results.py
Checklist:
Fixes: #{$ISSUE_NO}
.