Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Project: “I’m Feeling Lucky” Google Search
#31
I've been through this whole thread and everything in my code is working (running the exact code from this thread), except my browser won't launch with search results - here is my output when I run my .py script, which indicates success (code 200). Apologies, I'm probably missing something super obvious here - maybe I'm missing what should be run from cmd?

Output:
= RESTART: C:\Users\plenn\AppData\Local\Programs\Python\Python37-32\lucky.py = Hi! Please add search term: NHL NHL Googling... url: http://google.com/search?q=N H L 200 >>>
Quote
#32
Man, I'm having trouble with this project too. I'm getting no search results after passing the search terms into the run window. Here's my code:
#! 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'))

Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  "I'm Feeling Lucky" script problem (again) tab_lo_lo 7 1,335 Jul-23-2019, 11:26 PM
Last Post: snippsat
  Jump to next empty column with Google Sheets & Python Biks 0 161 Jun-14-2019, 07:28 PM
Last Post: Biks
  How to fix and extract Google CSE JSON API using Python.exe venkatsrrecruiter 1 260 May-04-2019, 07:33 PM
Last Post: venkatsrrecruiter
  Interfacing Google Chrome & Python akornrumpf 5 517 Mar-16-2019, 10:20 PM
Last Post: Larz60+
  RESTful API in Google Cloud Functions fggmack 0 336 Dec-30-2018, 06:58 AM
Last Post: fggmack
  Web application with google maps api jomonetta 1 600 Sep-13-2018, 05:23 AM
Last Post: buran
  Needs search the text from attachments in WordPress marcellofisher 1 634 Jul-09-2018, 07:49 AM
Last Post: alex6
  ImportError: No module named django.core.exceptions in google app engine timtinan37 4 1,382 Jun-18-2018, 01:34 PM
Last Post: Larz60+
  Cant get financial data from google Adam 0 1,218 Apr-11-2018, 03:02 PM
Last Post: Adam
  Different Output of findall and search in re module shiva 1 595 Mar-12-2018, 08:39 PM
Last Post: snippsat

Forum Jump:


Users browsing this thread: 1 Guest(s)