This curl request works:
curl --location --request GET 'https://www.target.com/s?searchTerm=sonic+frontiers&sortBy=relevance&category=5xtg5&facetedValue=nqueqc6d44fZ54jftZdq4mnZ2q830p6d44f&moveTo=product-list-grid' \
--header 'sec-ch-ua: "Brave";v="107", "Chromium";v="107", "Not=A?Brand";v="24"' \
--header 'sec-ch-ua-mobile: ?0' \
--header 'sec-ch-ua-platform: "Windows"' \
--header 'Upgrade-Insecure-Requests: 1' \
--header 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36' \
--header 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8' \
--header 'Sec-GPC: 1' \
--header 'Cookie: TealeafAkaSid=JA-JSAXRCLjKYhjV9IXTzYUbcV1Lnhqf; sapphire=1; visitorId=0184E4601D5A020183FFBB13380347CE; GuestLocation=33196|25.660|-80.440|FL|US'
I attempted to convert this to a Req.get! request, but I get an accessDenied error from the server.
req_url =
"https://www.target.com/s?searchTerm=sonic+frontiers&sortBy=relevance&category=5xtg5&facetedValue=nqueqc6d44fZ54jftZdq4mnZ2q830p6d44f&moveTo=product-list-grid"
headers = %{
"sec-ch-ua" => "\"Brave\";v=\"107\", \"Chromium\";v=\"107\", \"Not=A?Brand\";v=\"24\"",
"sec-ch-ua-mobile" => "?0",
"sec-ch-ua-platform" => "Windows",
"Upgrade-Insecure-Requests" => 1,
"User-Agent" =>
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36",
"Accept" =>
"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8",
"Sec-GPC" => 1,
"Cookie" =>
"TealeafAkaSid=JA-JSAXRCLjKYhjV9IXTzYUbcV1Lnhqf; sapphire=1; visitorId=0184E4601D5A020183FFBB13380347CE; GuestLocation=33196|25.744|-80.292|FL|US"
}
html = Req.get!(req_url, headers: headers, follow_redirects: true)
Error:
%Req.Response{
status: 403,
headers: [
{"connection", "close"},
{"content-length", "32"},
{"server", "Varnish"},
{"retry-after", "0"},
{"content-type", "application/json"},
{"accept-ranges", "bytes"},
{"date", "Tue, 06 Dec 2022 00:28:18 GMT"},
{"set-cookie",
"TealeafAkaSid=JA-JSAXRCLjKYhjV9IXTzYUbcV1Lnhqf; Expires=Thu, 05 Jan 2023 00:28:18 GMT; Path=/; Domain=target.com;"},
{"clientgeo", "US"},
{"clientip", "75.33.221.151"},
{"x-frame-options", "SAMEORIGIN"},
{"content-security-policy", "frame-ancestors 'self' https://*.target.com;"},
{"x-xss-protection", "1; mode=block"},
{"x-content-type-options", "nosniff"},
{"referrer-policy", "no-referrer-when-downgrade"},
{"strict-transport-security", "max-age=31536000; includeSubDomains"},
{"cache-control", "no-cache"}
],
body: %{"accessDenied" => "75.33.221.151"},
private: %{}
}
What am I doing wrong trying to convert this working curl into an Elixir Req.get! request? Thank you!