0

I tried to get html code from a site name dcinside in Korea, i am using requests but cannot get html code

and this is my code

import requests
url = "http://gall.dcinside.com/board/lists/?id=bitcoins&page=1"
req = requests.get(url)
print (req)
print (req.content)

but the result was

enter image description here

Why I cannot get html codes even using requests??

2 Answers 2

5

Most likely they are detecting that you are trying to crawl data dynamically, and not giving any content as a response. Try pretending to be a browser and passing some User-Agent headers.

headers = {
    'User-Agent': 'My User Agent 1.0', 
    'From': '[email protected]'
}

response = requests.get(url, headers=headers)

# use authentic mozilla or chrome user-agent strings if this doesn't work
Sign up to request clarification or add additional context in comments.

Comments

1

Take a look at this:

  1. Python Web Crawlers and "getting" html source code

Like the guy said in the aforementioned post, you should use urllib2 which will allow you to easily obtain web resources.

1 Comment

using urllib2 does not seem to be working with the website OP wants to fetch.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.