python - HTTP Get Request "Moved Permanently" using HttpLib -


scope:

i trying write web scrapper this specific page. have pretty strong "web crawling" background using c#, httplib beating me off.

problem:

when trying make http get request page specified above "moved permanently", points same url. can make request using requests lib, want make work using httplib can understand doing wrong.

code sample:

i new python, wrong language guideline or syntax c#'s fault.

import httplib  # wrapper "http get" request class httpclient(object):     def httpget(self, url, host):         connection = httplib.httpconnection(host)         connection.request('get', url)         return connection.getresponse().read()   # using "httpclient" class httpclient = httpclient()  # full url need make request : https://420101.com/strain-database  httpresponsetext = httpclient.httpget('www.420101.com','/strain-database') print httpresponsetext 

i want make work using httplib library, instead of requests or other fancy 1 because feel missing small here.

the problem i've had little or caffeine in system.

to https, needed httpsconnection class.

also, there no 'www' in address wanted get. so, shouldn't included in host.

both of wrong addresses redirect me correct one, 301 error code. if using requests or more full featured module, have automatically followed redirect.

my validation:

c = httplib.httpsconnection('420101.com') c.request("get", "/strain-database") r = c.getresponse() print r.status, r.reason  200 ok 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -