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控制台客户端的SOAP消息   java camunda异常找不到id为空的任务任务   java如何将json文件转换为以下格式{“Description”:“Cmd是一个开源工具”,数据{“别名”:“xCmd”,“软件”:“xCmd”,“_raw”:“}   java在Hibernate期间清理连接池花费的时间太长   用Java实现基本FTP客户端的socket   Java生成文本文件格式的格式化报告   java hibernate createQuery vs get   TriggerBuilder<Trigger>类型中带有Schedule(ScheduleBuilder<SBT>)的java不适用于参数(可变触发器)   JavaSwing:GlassPane防止鼠标指针更改   java使用for循环创建上下三角形   maven“Java Home”在cmd中运行“mvn v”时不显示   java客户端无法联机连接到服务器   java面向对象程序设计问题   java如何按升序和降序对hashmap数据进行排序   java为什么JPanel从不调用reapint