0

To receive an answer from requests.get I should provide it cookies and User-Agent.

Here is my code:

URL = 'https://www.alljobs.co.il/SearchResultsGuest.aspx'
headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:80.0) Gecko/20100101   Firefox/80.0',
    'Cookie': 'some Cookie string'
}

def get_html(url, params=''):
    r = requests.get(url, headers=headers, params=params)
    return r.text

params = {'page': 1, 'position': '765', 'type': '', 'city': '', 'region': ''}
html = get_html(URL, params=params)

I take the cookies and User-Agent from the browser's debugger. The question if there more elegant ways to do it, I mean not to copy past it manually.

martineau
  • 119,623
  • 25
  • 170
  • 301
  • You could [convert](https://curl.trillworks.com/) cURL command to python if that helps - that way you don't need to manually fill all the params & cookies – help-ukraine-now Sep 21 '20 at 14:39
  • Do you get the cookie from the first call? [Other StackOverflow query on same issue](https://stackoverflow.com/questions/31554771/how-to-use-cookies-in-python-requests) – JoySalomon Sep 21 '20 at 14:59

0 Answers0