Created
August 9, 2012 09:58
-
-
Save lanhao34/3302826 to your computer and use it in GitHub Desktop.
pyquery :contains error
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import urllib | |
from pyquery import PyQuery as pq | |
import sys | |
import re | |
keyword="黑魔女学园 720P TSDM" | |
s_utf=keyword#.decode(sys.stdin.encoding).encode("utf-8") | |
url_str='http://bt.ktxp.com/search.php?keyword=%s'%urllib.quote(s_utf) | |
d = pq(url=url_str) | |
div=d('tbody tr') | |
diva=div('.title_s a') | |
for i in diva("[href^='/html']"): | |
print re.sub(r'(?=\<).*?(?<=>)','', pq(i).html()) | |
for i in diva("[href$='.torrent']"): | |
print pq(i).attr('href') | |
for i in div(":contains(':')"): | |
print pq(i).attr('title') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment