chevron_left chevron_right
Login Register invert_colors photo_library

Stay updated and chat with others! - Join the Discord!
Thread Rating:
  • 0 Vote(s) - 0 Average

GiyPy (Google Search Explained) filter_list
GiyPy (Google Search Explained) #1
This is an explanation to the google search for GiyPy

I'm not good at explaining things, but here goes nothing...

Taking you step by step, We start by generating a url using whatever search you input.

So for example, if I were to search for kittens, I would end up with this URL.
We then use the Python module, Urllib to open, parse, read and decode the data.
encoded = urllib.parse.quote("kittens")
rawData = urllib.request.urlopen(""+encoded).read().decode("utf-8")
Now that we have our raw data, we can use json.loads to take a JSON string and turn it into a python dictionary.
From there, we can easily get the information we need.
jsonData = json.loads(rawData)

This is what the json data looks like:
{"responseData": {"results":[{"GsearchResultClass":"GwebSearch","unescapedUrl":"\u003dFtX8nswnUKU","url":"","visibleUrl":"","cacheUrl":"\","title":"\u003cb\u003ekittens\u003c/b\u003e inspired by \u003cb\u003ekittens\u003c/b\u003e - YouTube","titleNoFormatting":"kittens inspired by kittens - YouTube","content":"Sep 1, 2008 \u003cb\u003e...\u003c/b\u003e The Official Facebook Page-\u003cb\u003eKittens\u003c/b\u003e-Inspired-by\n-\u003cb\u003eKittens\u003c/b\u003e/49930012799."}]}}

Now, You are probably thinking what the fuck is this crap.
Because I did the same :|
Bunched together, Its a little hard to understand, but if we split it apart, it becomes alot easier to read.

"title":"\u003cb\u003ekittens\u003c/b\u003e inspired by \u003cb\u003ekittens\u003c/b\u003e - YouTube",
"titleNoFormatting":"kittens inspired by kittens - YouTube",
"content":"Sep 1, 2008 \u003cb\u003e...\u003c/b\u003e The Official Facebook Page-\u003cb\u003eKittens\u003c/b\u003e-Inspired-by\n-\u003cb\u003eKittens\u003c/b\u003e/49930012799."

As you can see, it begins the entire dictionary with resonseData, shortly followed by results.
Inside that is all the information we need.

Since we converted the data to a python dictionary, we can very easily select the data we need like so:
data = jsonData["responseData"]["results"][0]

if we look at the jsonData as a box, we have something like this:

[Image: screenshot_34.png]

Inside the responseData is results. Inside results is four lots of gSearchResultClass and in each of them there is more information.

The previous code opens the responseData box and the results box, Then opens the first box it finds. ( 0 is the first, 1 is the second ect )

All we need to do now is unquote the data, and print what we want.

title = data["title"]
link = urllib.parse.unquote(data["url"])

print("I found: %s \n %s" % (title, link))

This returns:

I found: kittens inspired by kittens - YouTube

If this isn't explained enough, or im completely wrong, Please feel free to post a reply with whatever I failed at.
[Image: screenshot_108.png]


Users browsing this thread: 1 Guest(s)