I want to search a text in Google using a python script and return the name, description and URL for each result. I'm currently using this code:
from google import search ip=raw_input("What would you like to search for? ") for url in search(ip, stop=20): print(url)
This returns only the URL's. How can I return the name and description for each URL?
googlesearch is a Python library for searching Google, easily. googlesearch uses requests and BeautifulSoup4 to scrape Google.
I assume you are using this library by Mario Vilas because of the stop=20
argument which appears in his code. It seems like this library is not able to return anything but the URLs, making it horribly undeveloped. As such, what you want to do is not possible with the library you are currently using.
I would suggest you instead use abenassi/Google-Search-API. Then you can simply do:
from google import google num_page = 3 search_results = google.search("This is my query", num_page) for result in search_results: print(result.description)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With