应该对此脚本进行哪些更改以使其打印出所需的结果?
def dummy(url):
req = urllib.request.urlopen(url).read().decode('utf-8').replace("\n","")
getTag = re.search('<div class="eps_lst_tbn">(.*?)<div class="clear"></div>', req).group(1)
judul = re.findall('<div class="node">\r\t\t\t<div>(.*?)</div>',getTag)
link = re.findall('<a href="(.*?)">',getTag)
episode = re.findall('</a>\r\t\t\t<div>(.*?)</div>',getTag)
l=[]
num = 1
for i in link:
x = '<br/>(%s) %s - %s <a target="_blank">%s</a>' %(num,judul,episode,i)
l.append(x)
num = num+1
string = ''.join(l[0:3])
return string
目前的结果:
(1) ['a', 'b', 'c'] - ['1', '2', '3'] <u>http://url.com/a/1/</u>
(2) ['a', 'b', 'c'] - ['1', '2', '3'] <u>http://url.com/b/2/</u>
(3) ['a', 'b', 'c'] - ['1', '2', '3'] <u>http://url.com/c/3/</u>
期望的结果:
(1) a - 1 <u>http://url.com/a/1/</u>
(2) b - 2 <u>http://url.com/b/2/</u>
(3) c - 3 <u>http://url.com/c/3/</u>
答案 0 :(得分:1)
%0D%0A
和if (strpos($string, "..") !== false || strpos($string, "._") !== false || strpos($string, "-.") || strpos($string, ".-"))
不是字符串,它们是字符串列表。如果要为每个字符串显示单个字符串,则必须使用索引。
judul