title: HTTP error 403 in Python 3 Tumblr Scraping even after User-Agent headers added
body: <p>I try to crawl the most recent images that contain specific keyword tags from tumblr without logining or using api. However I receive error 403 when I run my code, even though I have added User-Agent data into the headers.
  Could anyone help me? Thank you and sorry about my poor English.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>import urllib.request
  import urllib.parse
  from bs4 import BeautifulSoup
  import re   
  
  url='https://www.tumblr.com/search/flowers/recent'
  
  data={}
  data['q']='flowers'
  data['sort']='recent'
  data['post_view']='masonry'
  data['blogs_before']=8
  data['num_blogs_shown']=8
  data['num_posts_shown']=0
  data['before']=0
  data['blog_page']=1
  data['post_page']=1
  data['filter_nsfw']='true'
  data['filter_post_type']='photo'
  data['next_ad_offset']=0
  data['ad_placement_id']=0
  data['more_posts']='true'
  
  
  data=urllib.parse.urlencode(data).encode('utf-8')    
  req=urllib.request.Request(url,data)
  
  #add headers
  req.add_header('User-Agent','Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.94 Safari/537.36')
  
  response=urllib.request.urlopen(req)        
  html=response.read().decode('utf8')
  
  
  
  Traceback (most recent call last):
    File "C:\Users\D47\Desktop\tumblr.py", line 29, in &lt;module&gt;
      response=urllib.request.urlopen(req)
    File "D:\Temp\python\lib\urllib\request.py", line 162, in urlopen
      return opener.open(url, data, timeout)
    File "D:\Temp\python\lib\urllib\request.py", line 471, in open
      response = meth(req, response)
    File "D:\Temp\python\lib\urllib\request.py", line 581, in http_response
      'http', request, response, code, msg, hdrs)
    File "D:\Temp\python\lib\urllib\request.py", line 509, in error
      return self._call_chain(*args)
    File "D:\Temp\python\lib\urllib\request.py", line 443, in _call_chain
      result = func(*args)
    File "D:\Temp\python\lib\urllib\request.py", line 589, in http_error_default
      raise HTTPError(req.full_url, code, msg, hdrs, fp)
  urllib.error.HTTPError: HTTP Error 403: Forbidden
  </code></pre>