Python Forum
"I'm Feeling Lucky" script problem (again)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
"I'm Feeling Lucky" script problem (again)
#1
I didn't get any replies to the other related thread; and, because one other person in that thread had the same problem as me with no answers I thought it appropriate to start a new thread.

Original question:

"Man, I'm having trouble with this project too. I'm getting no search results after passing the search terms into the run window."

My script returns this output:
"Googling...
None
Press any key to continue . . ."

My script:
#! python3
# lucky.py - Opens several Google search results.
 
import webbrowser, bs4, requests, sys
 
print('Googling...') # display text while downloading the Google page
res = requests.get('http://google.com/search?q=' + ' '.join(sys.argv[1:]))
print(res.raise_for_status())
 
# Retreive top search result links.
soup = bs4.BeautifulSoup(res.text, "html.parser")
 
# Open a browser tab for each result
linkElems = soup.select('.r a')
numOpen = min(5, len(linkElems))
for i in range(numOpen):
    webbrowser.open('http://google.com' + linkElems[i].get('href')) 
Reply


Messages In This Thread
"I'm Feeling Lucky" script problem (again) - by tab_lo_lo - Jul-11-2019, 03:21 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  requests problem in python script "content type" abdlwafitahiri 4 3,177 Dec-29-2019, 02:29 PM
Last Post: abdlwafitahiri
  Project: “I’m Feeling Lucky” Google Search Truman 31 28,390 Jul-09-2019, 04:20 PM
Last Post: tab_lo_lo
  Problem With Simple Multiprocessing Script digitalmatic7 11 9,221 Apr-16-2018, 07:18 PM
Last Post: digitalmatic7

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020