|||
import urllib2 # the urllib2 module defines functions and classes which help in opening URLs (mostly HTTP) in a complex world - basic and digest authentication, redirections, cookies and more.
url1 = 'http://www.oldbaileyonline.org/print.jsp?div=t17800628-33'
response1 = urllib2.urlopen(url1) # call the function urlopen which is stored in the urllib2 module to open the specified URL. Then save the open version of the requested webpage into the variable response1.
webContent1 = response1.read() # copy the contents of the requested open webpage into the vatiable webContent1.
f = open('obo_webpage','w')
f.write(webContent1)
f.close
print webContent1 [0:300] # index the first 300 rows.
url2 = 'http://dict.youdao.com/search?le=eng&q=redirection&keyfrom=dict.top'
response2 = urllib2.urlopen (url2)
webContent2 = response2.read ()
print webContent2
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-7-17 23:14
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社