Skip to content

Instantly share code, notes, and snippets.

@lanhao34
Created August 9, 2012 09:58
Show Gist options
  • Save lanhao34/3302826 to your computer and use it in GitHub Desktop.
Save lanhao34/3302826 to your computer and use it in GitHub Desktop.
pyquery :contains error
# -*- 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