sudo easy_install pyquery
from pyquery import PyQuery as pq
html = pq(url=u'http://seam.ustb.edu.cn:8080/jwgl/index.jsp')
#现在已经获取了本科教学网首页的html
classes = html('.haveclass')
#通过类名获取元素
#如果你对jQuery熟悉的话,那么你现在肯定明白pyQuery的方便了
更多用法参见pyQuery API
import urllib
import urllib2
import cookielib
cj = cookielib.CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
opener.addheaders = [('User-agent','Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)')]
urllib2.install_opener(opener)
req = urllib2.Request("http://seam.ustb.edu.cn:8080/jwgl/Login",urllib.urlencode({"username":"41255029","password":"123456","usertype":"student"}))
req.add_header("Referer","http://xxoo.com")
resp = urllib2.urlopen(req)
#这里面用到了cookielib,我不太清楚,以后慢慢了解吧
#还用到了urllib和urllib2,urllib2大概是urllib的扩展包【233想到了三国杀
html = pq(url=u'http://seam.ustb.edu.cn:8080/jwgl/index.jsp')
self.render("index.html",data=html('.haveclass'))
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有