-2

Right now I am trying to figure out how to take a row of data, maybe like 50 entries max, and enter it individually into a search bar. But first I need to understand the beginning concepts so I want to do a practice program that could take info from an Excel sheet and enter into a Google search or YouTube, for example.

My problem is there seems to be no resource on how to do this for beginners. All posts I have read are either parts of the whole problem or not related to actually using a search bar but instead creating one. Even then every post I read has 100 plug-ins I could possibly add.

I'm just looking for a consistent explanation to where I can grasp how I can manipulate code in order to use a search bar function.

pnuts
  • 58,317
  • 11
  • 87
  • 139
Sean
  • 55
  • 1
  • 2
  • 6
  • Do you mean you are trying to submit data to a Google (or YouTube) search, i.e. use your data to perform a search? – redbirdo Jun 18 '15 at 13:22
  • You can use csv module to read excel files that were saved as csv. If you must read excel in native mode, use xlrdr module. To search, look at a url that is created by the search engine when you create a manual search with several terms. – joel goldstick Jun 18 '15 at 13:24
  • Can you elaborate on that? Im trying to break down this problem into two steps. First step is try and figure out how to use a searchbar using python. Google and youtube are simply examples. The real project that requires it is something for work to search a database. part two would be grabbing the contents of an excel cell and placing it into the search bar. So my question at this point is how do I write a program that can access a webpage that has the search bar then input data into it? – Sean Jun 18 '15 at 18:13

1 Answers1

0

To perform a web search (Google, YouTube or whatever) from a program you need to execute the search, either by building up and calling an appropriate search URL or by making a call to an API provided by that site.

The article 'Python - Search for YouTube video' provides a code sample and explanation of how to generate and call a URL to perform a YouTube keyword search. You could do something similar for a Google search by analysing the URL from the result of a Google search, or try searching for 'Python submit google search url'.

The above approach is simplistic and relies on the URL structure for a particular site staying the same. A more complex, reliable and flexible approach is to use the API. For YouTube:

redbirdo
  • 4,937
  • 1
  • 30
  • 34