Python Request HTTP Page and Use The Source Information -


i'm looking request webpage python , source code string (my page has text exmaple year2012 no html or other codes if view source see year2012 need)

for example have c# code want in python:

string webclient = new webclient().downloadstring(webpage); 

if create myscript.php , enter year2012 string webclient = "year2012" if change later on , program check webpage ever change. want same thing in python windows idea how?

thanks!

i suggest using package requests.here code snipet may meet need:

import requests r = requests.get('https://github.com/timeline.json') 

edit:

or may use default package in python: urllib2, simple example:

import urllib2 f = urllib2.urlopen('http://www.python.org/') print f.read(100) 

the output:

<!doctype html public "-//w3c//dtd html 4.01 transitional//en"> <?xml-stylesheet href="./css/ht2html 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -