Python Forum
search for a data in my browser via script
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
search for a data in my browser via script
#1
Hello guys,
Here i am writing a script which will open my chrome browser and opens the URL www.google.com.
But how to search for a data via script.
for example i need to search for 'Rose' in google.com via script.
how to do that?

import webbrowser
url="www.google.com"
chrome_path = 'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe %s'
webbrowser.get(chrome_path)
webbrowser.open(url)
Reply
#2
Start with reading some basic tutorials to get taste for web scraping
https://python-forum.io/Thread-Web-Scraping-part-1
https://python-forum.io/Thread-Web-scraping-part-2

Note that depending on site you want to scrap/get data from, there might be API that generally should be used if available.
Reply
#3
Hello!

Selenium is a good choice for such a task.
Sorry for the outer how to but I never use it before.
You may like this:

In [1]: from google import search

In [2]: for result in search("Python forum"):
  ...:     print(result)
  ...:     
http://www.python-forum.org/
https://python-forum.io/
https://python-forum.io/Forum-General-Coding-Help
https://python-forum.io/Forum-Homework
https://python-forum.io/Forum-News-and-Discussions
https://python-forum.io/Forum-Tutorials
https://www.python.org/community/
https://www.reddit.com/r/Python/comments/1lqr8j/what_are_the_best_python_forums_to_hang_out_in/
http://www.dreamincode.net/forums/forum/29-python/
http://forums.devshed.com/python-programming-11/
https://www.quora.com/What-are-some-active-Python-forums-for-beginners
http://www.codingforums.com/python/
https://www.python-forum.de/
https://forum.micropython.org/
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#4
If you just want to search and display that in browser,
you can do it like this.
import webbrowser

search_word = 'Rose'
url = 'https://www.google.com/#q={}'.format(search_word)
# Open url in new tab in default browser
webbrowser.open_new_tab(url)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  webdriver.remote to connect back existing browser without open new browser? gahhon 6 6,628 Feb-26-2019, 03:53 PM
Last Post: gahhon

Forum Jump:

User Panel Messages

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