querying url / webpages using python

Although querying webpages using python can be performed using urllib, it seems a simpler way is to use library called “requests“.

Installation

  1. go to http://www.python-requests.org and download zip file (other installation instructions are available, check requests documentation)
  2. save zip file into your python installation folder or any where else in your computer
  3. unzip content
  4. open cmd shell and go to new folder
  5. from there, run “python setup.py install”

Done!
You should know be able to run “import requests” from python cmd

Query for an url

import requests
link = "http://www.somesite.com/"
f = requests.get(link)
print f.text

sources

Post a Comment

Your email is never published nor shared. You're allow to say what you want...