Skip to content
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

Merged
merged 8 commits into from
Oct 13, 2022
Merged

Update open_google_results.py #7085

merged 8 commits into from
Oct 13, 2022

Conversation

cj-praveen
Copy link
Contributor

@cj-praveen cj-praveen commented Oct 13, 2022

Describe your change:

Created web_programming/open_google_results.py

  • Add an algorithm?
  • Fix a bug or typo in an existing algorithm?
  • Documentation change?

Checklist:

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized.
  • I know that pull requests will not be merged if they fail the automated tests.
  • This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
  • All new Python files are placed inside an existing directory.
  • All filenames are in all lowercase characters with no spaces or dashes.
  • All functions and variable names follow Python naming conventions.
  • All function parameters and return values are annotated with Python type hints.
  • All functions have doctests that pass the automated testing.
  • All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation.
  • If this pull request resolves one or more open issues then the commit message contains Fixes: #{$ISSUE_NO}.

@cj-praveen cj-praveen requested a review from cclauss as a code owner October 13, 2022 06:11
@algorithms-keeper algorithms-keeper bot added enhancement This PR modified some existing files awaiting reviews This PR is ready to be reviewed labels Oct 13, 2022
res = get(
url,
headers={
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:98.0) Gecko/20100101 Firefox/98.0"
Copy link
Member

@cclauss cclauss Oct 13, 2022

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?

Copy link
Contributor Author

@cj-praveen cj-praveen Oct 13, 2022

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!

Copy link
Member

Choose a reason for hiding this comment

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

Why is it better?

Copy link
Contributor Author

@cj-praveen cj-praveen Oct 13, 2022

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:

Running my program

C:\> python crawl_google_results.py how to code on ipad
Googling.....

It opens the search result link or url.

Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah! sounds good

Copy link
Contributor Author

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.

@cclauss So can you merge now?

from bs4 import BeautifulSoup
from fake_useragent import UserAgent
from requests import get
Copy link
Member

Choose a reason for hiding this comment

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

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok sure!

Copy link
Contributor Author

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!

@mleiyu
Copy link

mleiyu commented Oct 13, 2022 via email

@cj-praveen cj-praveen changed the title Update crawl_google_results.py Update open_google_results.py Oct 13, 2022
@algorithms-keeper algorithms-keeper bot removed the awaiting reviews This PR is ready to be reviewed label Oct 13, 2022
@cclauss cclauss added hacktoberfest hacktoberfest-accepted Accepted to be counted towards Hacktoberfest labels Oct 13, 2022
@cclauss cclauss merged commit f176786 into TheAlgorithms:master Oct 13, 2022
@cj-praveen
Copy link
Contributor Author

@cclauss Thanks :)

@CaedenPH
Copy link
Contributor

@cclauss The pre-commit on this test failed

@cclauss
Copy link
Member

cclauss commented Oct 13, 2022

Yes. I clicked too quickly. I think we pre-commit fixed it on bugbear.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This PR modified some existing files hacktoberfest hacktoberfest-accepted Accepted to be counted towards Hacktoberfest
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants