+ 7
[SOLVED] why dose this only output []?
in my code, im trying to get data from google search results. but i always get [] i think the problem is with the where_2_find_it variable. but im not sure. heres the code https://code.sololearn.com/cGh9vtNMXL25/#py
1 Antwort
+ 5
Well it has multiple problems:
1.yes the xpath adress seems to be non-working
2.you have to make a string if you want to print it use html.tostring(doc)
(Warning this function takes a single element only doc.xpath(xpath) in your code returns a list so you have to choose an element from it eg html.tostring(doc[0]) see my code below)
My advices for you
1. Search a html tag witch contains all of the search res
in our case <div id="ires">
2.Then inside this tag search for a html tag witch contains an individual search res in our case <div class="g">
3.Then get your data out from the <div class="g"> tag
My code does the first 2 steps for you the third step is up to you:
https://code.sololearn.com/cF9AXMiY802Z/#py