code 1 can run in python2.6 code1 is the following #coding:utf-8 import urllib import lxml.html down='http://frux.wikispaces.com/' root=urllib.urlopen(down).read() root=lxml.html.fromstring(root) file=root.xpath('//a') for i in file: str1=i.text_content() if str1.find('pdf') >-1 : str2='http://frux.wikispaces.com/file/view/'+str1 print str2 i usr command : 2to3-3.2 ~/xml.py -w to get code2 code2 is the following #coding:utf-8 import urllib.request, urllib.parse, urllib.error import lxml.html down='http://frux.wikispaces.com/' root=urllib.request.urlopen(down).read() root=lxml.html.fromstring(root) file=root.xpath('//a') for i in file: str1=i.text_content() if str1.find('pdf') >-1 : str2='http://frux.wikispaces.com/file/view/'+str1 print(str2) what is the matter?
participants (1)
-
水静流深