i have a redirection url
www.test.com
it will redirect me to
www.test.com/XXYYXXYY
ans every time when i open it will redirect me to a new url ( XXYYXXYY will change every time )
so i want to save them into a CSV file
import urllib2
import csv
import sys
url = 'http://www.test.com'
u = urllib2.urlopen(url)
localFile = open('file.csv', 'w')
localFile.write(u.read())
localFile.close()
is this a correct code ?
thank you
geturl() will give you the final URL
import urllib2
import csv
import sys
url = 'http://www.test.com'
u = urllib2.urlopen(url)
localFile = open('file.csv', 'w')
localFile.write(u.geturl())
localFile.close()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.