python 爬取td标签对应的值

641次阅读
没有评论
python

[root@yyjk /tmp]#cat a2.py 
# !/usr/bin/env python
# -*- coding: utf-8 -*-
import urllib2
import urllib
import cookielib
import json
import httplib
import re
import requests
import StringIO
import time
from lxml import etree
s = requests.session()
print s.headers
headers = {
    ‘User-Agent’: ‘Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:54.0) Gecko/20100101 Firefox/54.0’
}


data = {‘username’:’thinkgem’,’password’:’R6k_5QTs’}
# data = urllib.urlencode(data)
response = s.post(login_url, data=data, headers=headers,timeout=10)

data={‘pageNo’:’1′,’pageSize’:’100′}
fh2=open(‘fh2.html’,’r’)
fh3=fh2.read()
htmlEmt=etree.HTML(fh3)
result= htmlEmt.xpath(‘//td’)
fo

神龙|纯净稳定代理IP免费测试>>>>>>>>天启|企业级代理IP免费测试>>>>>>>>IPIPGO|全球住宅代理IP免费测试

相关文章:

版权声明:Python教程2022-10-25发表,共计590字。
新手QQ群:570568346,欢迎进群讨论 Python51学习