title: How can I fix HTTP error 400 in this python code?
body: <p>I'm trying to scrap a post from Facebook. Keeps returning HTTP error 400. Any clues?</p>
  
  <p>Here are my codes:</p>
  
  <pre><code>try:
      req=urllib.request.Request(url)
      with urllib.request.urlopen(req) as response:
          the_page=response.read()
      if response.getcode()==200:
          data=json.loads(response.read().decode('utf-8'))
          print(data)
  except Exception as e:
          print(e)
  </code></pre>
  
  <p>and error is as below:</p>
  
  <pre><code>&gt;&gt;&gt; response=urllib.request.urlopen(req)
  Traceback (most recent call last):
    File "&lt;pyshell#3&gt;", line 1, in &lt;module&gt;
      response=urllib.request.urlopen(req)
    File "C:\Users\sknkuh10\AppData\Local\Programs\Python\Python37-32\lib\urllib\request.py", line 222, in urlopen
      return opener.open(url, data, timeout)
    File "C:\Users\sknkuh10\AppData\Local\Programs\Python\Python37-32\lib\urllib\request.py", line 531, in open
      response = meth(req, response)
    File "C:\Users\sknkuh10\AppData\Local\Programs\Python\Python37-32\lib\urllib\request.py", line 641, in http_response
      'http', request, response, code, msg, hdrs)
    File "C:\Users\sknkuh10\AppData\Local\Programs\Python\Python37-32\lib\urllib\request.py", line 569, in error
      return self._call_chain(*args)
    File "C:\Users\sknkuh10\AppData\Local\Programs\Python\Python37-32\lib\urllib\request.py", line 503, in _call_chain
      result = func(*args)
    File "C:\Users\sknkuh10\AppData\Local\Programs\Python\Python37-32\lib\urllib\request.py", line 649, in http_error_default
      raise HTTPError(req.full_url, code, msg, hdrs, fp)
  urllib.error.HTTPError: HTTP Error 400: Bad Request
  &gt;&gt;&gt; 
  </code></pre>