HTML为人类解析宏事物。

requests-html-macros的Python项目详细描述


https://travis-ci.org/erinxocon/requests-html-macros.svg?branch=masterhttps://img.shields.io/pypi/v/requests-html-macros.svg?maxAge=2592000https://img.shields.io/pypi/l/requests-html-macros.svg?maxAge=2592000

requests html宏是一个已经很好的html解析库Requests-Html

这个库的目的是帮助解析web比用请求html更容易!创建可在不同网站/会话上重用的宏! 你能用请求html手工完成这个任务吗,是的,可能很简单,但是我只意识到liek开发这个库的一半,然后就好像搞砸了一样,让我们把它推出来!

示例

fromtimeimportsleepfromrequests_html_macroimportMacrofromrequests_htmlimportHTMLSession# Create a standard requests-html sessionsession=HTMLSession()response=session.get('http://python.org')# Create a macro with the responsemacro=Macro(response=response)# Create a macro that uses the parse library to search through the html@macro.search_pattern('Python is a {} language',first=True)deffoo(data):print(data[0])# Creates a macro that uses a css selector@macro.css_selector('#about',first=True)deffoo1(data):print(data.text)@macro.xpath('//a',first=True)deffoo2(data):print(data)whileTrue:macro.parse()sleep(30)macro.response=session.get('http://python.org')

安装

$ pip install requests-html-macro

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java获取textview的文本并将其粘贴到另一个上   java ImageIO。write()不保存文件   java H2数据库排序字符串时间戳,格式为yyyyMMdd'T'hh:mm:ss。SSSSSSS'Z'   java匿名类与静态字段   java将一个句子拆分为字符串数组,并保留特殊字符或空格   JavaBIRT报告引擎。计算Javascript表达式时出错   日志表的java MySQL隔离级别读取未提交   java Android调用意图权限   java如何在iText 7中查找文本位置和边界   从Groovy调用Java类主方法时,避免参数数量不正确   java libGDX:在批处理调用stage constructor时,为舞台上的演员绘制纹理作为背景   java randoop可以利用usermade JUnit测试生成测试吗?   java Eclipse工作区将不再显示我的项目