venomnert
Context:
I am trying to dynamically make google search requests. However, it seems like google doesn’t offer an API for it. So my next approach is to use httpoison to make a google search via query parameter and parse through the results.
Problem:
However, I am running to a problem in which google doesn’t recognize my httpoison request as a legitimate request.
Question:
- Have any of you guys/gals worked with google search?
- How can I send a legitimate request via HTTPoison?
Trending in Questions
Hey guys,
I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly
Do you guys have any suggestions what is the best prac...
New
Hello!
Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app.
I creat...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
Anyone here using Honeybadger?
My Honeybadger account is being overwhelmed with noise from some bots. Seeing a lot of
Bandit.HTTPError...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixir-ls
- #elixirconf-us
- #ai
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 7- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
Phillipp
I can’t tell you exactly what you need to include, but here is a good approach to find out what you need:
Make a manual request via your browser and record it using the devtools. Make sure you are in incognito mode so you don’t have any session data.
Recreate the request, including all the headers and parameters using a HTTP tool, e.g. Postman.
If step 2 works, then start to remove some headers which you think are not needed. The goal is to end up with just the stuff you need.
Recreate the request using HTTPoison. It’s mostly just headers and in some cases you might also need some cookies.
The approach is pretty simple. It’s basically just emulating a real person. Have a look at headers like User-Agent, Accept, etc. Some sites try to be fancy and use those to detect crawlers.
If, for some reason, you need a cookie. Then figure out where and how the cookie is set. This means, you might end up with an extra request to obtain a cookie which you then use for the following requests.
preciz
Or you can “copy as cURL” the request (in most browsers) and do the same with cURL.
Also startpage.com returns google results, maybe that is easier to scrape? (just an idea, something to try)
Phillipp
Or use the cURL command to import into Postman
Fiddling around with a cURL command that contains headers and cookies is pretty awful 
hubertlepicki
Just to help you with some future problems, there are more that you probably don’t expect. Let me list them below:
This goes against Google’s TOS. You can be in legally not great position if you do that. I’m not saying Google will actually come after you but you have to be aware that this is not valid usage of the service, from Google’s point of view.
They not only say this is a violation and not do anything about it, but they will actively detect and block you from scraping search results. Google builds profiles of all browsers / users with cookies and also IP addresses, and it will record these, do some matching behind the scenes and figure out that there is a suspicious browser, coming from a suspicious IP address, and will do several things: first, they will present you with a captcha to make sure “you are not a robot”. They can also block you even if you keep solving the captcha, effectively blocking off the IP address from Google’s services. You will have to rotate the IP addresses on regular basis and build browsers’ “human-like” behavior pattern to prevent being detected. You probably want to slow things down, also visit other sites, make your profile seem like a real user etc.
This is still doable, esp. if you want to do it at small scale for own usage, but at large scale it becomes expensive, risky, and you may not want to do it.
_rubenfa
As @hubertlepicki have said, you have to mimic user behaviour to make sure it works. HttpPoison is not a good option for this job. Tools like Nightmare or Puppeter are better choices.
You have to take in mind stuff like the User-Agent of the browser, user typing speed, captchas, continuous layout changes, privacy popups etc.
Anyway, you have not said too much about what are you trying to do. Depending on the volume of requests, it can be relatively easy or hard and expensive.
venomnert
I feared this would be the case since they didn’t offer a public search api. I’ll keep this in mind.
venomnert
Gotcha. I was able to make the google request work using Postman and I noticed that the requested generated a cookie and token. And I wasn’t sure how I can create a token and cookie.