xpath

开线程爬取黑猫里的阿里投诉信息

感情迁移 提交于 2020-03-22 14:35:01
仅供学习,请适度开线程 一.代码 import requests from requests_html import HTMLSession import time from concurrent.futures import ThreadPoolExecutor import json pool = ThreadPoolExecutor(30) big_list = [] pool_name_list =[] session = HTMLSession() def dewu_company(x): try: print(f'第{x+1}页') params = { 'couid': '1878960481', 'type': '1', 'page_size': f'{(x + 1) * 10}', 'page': f'{x + 1}', # 'callback':'jQuery11', } url = 'https://tousu.sina.com.cn/api/company/received_complaints' res = requests.get(url, params=params, verify=False) info_list = res.json()['result']['data']['complaints'] for dict_info in info

How to fix “Field not found” error in case using two XPath expressions in single report?

不羁岁月 提交于 2020-03-22 11:47:49
问题 I've been struggling with my problem since 7 days. I have 1 XML input data and want to convert that into desired PDF file with line chart XML <?xml version="1.0" encoding="utf-8"?> <sample-data xmlns:ms="urn:schemas-microsoft-com:xslt" xmlns:ht="urn:xyz.com/xslt/extensions"> <section name="relative-performance"> <historic-valuations> <valuation-list> <valuation> <value>890000</value> <date>2014-12-01T00:00:00</date> </valuation> <valuation> <value>923789</value> <date>2015-12-01T00:00:00<

XQuery unexpected end of query on namespace declaration

喜你入骨 提交于 2020-03-21 05:58:22
问题 I'm trying to execute this query: declare variable $doc as xs:string external; declare namespace type4="http:///de/tudarmstadt/ukp/dkpro/core/api/segmentation/type.ecore"; fn:doc($doc)//type4:Lemma/@value within the BaseX java driver. The actual code snippet looks like this: String queryString = "declare variable $doc as xs:string external; " + "declare namespace type4=\"http:///de/tudarmstadt/ukp/dkpro/core/api/segmentation/type.ecore\"; " + "fn:doc($doc)//type4:Lemma/@value"; Set<String>

XQuery unexpected end of query on namespace declaration

只愿长相守 提交于 2020-03-21 05:58:19
问题 I'm trying to execute this query: declare variable $doc as xs:string external; declare namespace type4="http:///de/tudarmstadt/ukp/dkpro/core/api/segmentation/type.ecore"; fn:doc($doc)//type4:Lemma/@value within the BaseX java driver. The actual code snippet looks like this: String queryString = "declare variable $doc as xs:string external; " + "declare namespace type4=\"http:///de/tudarmstadt/ukp/dkpro/core/api/segmentation/type.ecore\"; " + "fn:doc($doc)//type4:Lemma/@value"; Set<String>

(21)odoo中的QWeb模板引擎

那年仲夏 提交于 2020-03-20 20:09:09
----------------- 更新时间 18:13 2016-04-05 星期二 ----------------- * 概述 QWeb是odoo主要模板引擎,采用xml表述,最后生成HTML文件 * 一般用法 #条件表达式 <t t-if="record.effort_estimate.raw_value > 0"> <li>Estimate <field name="effort_estimate"/></li> </t> 比较符号: lt(<) lte(<=) gt(>) gte(>=) 注 < <= 不能用在表达式中,只能用字母代替 # 输出值 t-esc 和 t-raw <t t-esc="record.message_follower_ids.raw_value" /> <t t-raw="record.message_follower_ids.raw_value" /> t-esc 过滤安全值,像html元素 t-raw 数据库中的原始数据 # 循环 <t t-foreach="record.message_follower_ids.raw_value" t-as="rec"> <t t-esc="rec" />; </t> t-foreach="record.message_follower_ids.raw_value.slice(0, 3)" 还可以切片

XML 命名空间(XML Namespaces)介绍以及节点读取方法

橙三吉。 提交于 2020-03-20 18:31:35
XML 命名空间提供避免元素命名冲突的方法。 命名冲突 在 XML 中,元素名称是由开发者定义的,当两个不同的文档使用相同的元素名时,就会发生命名冲突。 这个 XML 文档携带着某个表格中的信息: <table> <tr> <td>Apples</td> <td>Bananas</td> </tr></table> 这个 XML 文档携带有关桌子的信息(一件家具): <table> <name>African Coffee Table</name> <width>80</width> <length>120</length></table> 假如这两个 XML 文档被一起使用,由于两个文档都包含带有不同内容和定义的 <table> 元素,就会发生命名冲突。 XML 解析器无法确定如何处理这类冲突。 使用前缀来避免命名冲突 此文档带有某个表格中的信息: <h:table> <h:tr> <h:td>Apples</h:td> <h:td>Bananas</h:td> </h:tr></h:table> 此 XML 文档携带着有关一件家具的信息: <f:table> <f:name>African Coffee Table</f:name> <f:width>80</f:width> <f:length>120</f:length></f:table> 现在,命名冲突不存在了

How to select boolean-valued nodes in XPath?

爱⌒轻易说出口 提交于 2020-03-18 14:52:33
问题 I have an XML document and associated schema that defines several attributes as having the xs:boolean type. The lexical values for xs:boolean are true , false , 1 , and 0 , so it seems that to correctly select attributes with a particular boolean value I'd have to write something like: @attribute='true' or @attribute='1' or @attribute='false' or @attribute='0' This seems verbose. You might expect something like boolean(@attribute) to work, but the boolean function has different semantics. Is

WebDriver的定位元素方法

允我心安 提交于 2020-03-18 11:54:26
如果把页面上的元素看作人的话,在现实世界如何找到某人呢?方法有三: 一、通过人本身的属性,例如他的姓名,手机号,身份证号,性别,这些可区别他人的属性。在web页面上的元素也有这些属性,例如,id、name、class name、tag name等。 二、在找查某人的时候可以通过位置属性,例如,x国、x市、x路、x号。Xpath和CSS就提供了这种以标签名为层级关系的定位方式。 三、可以借助相关他人的属性来找到某人,例如,我没有小明的联系方式,但我有他爸爸的手机号,那么通过他爸爸手机号也可以找到小明。Xpath和CSS同样提供通过相关元素来查找最终元素的方式。 WebDriver提供多种元素定位方法,下面用Python语言来介绍这些元素定位: 1、id定位 HTML规定id属性在HTML文档中必须是唯一的,这类似于公民的身份证号。webdriver提供的id定位方法就是通过元素的id属性来查找元素。例如通过id定位浏览器下百度输入框与百度搜索按钮,用法如下: find_element_by_id("kw") 百度输入框 find_element_by_id("su") 百度搜索 即find_element_by_id()方法通过id属性来定位元素。 2、name定位 HTML规定name来指定元素的名称,就像人的姓名,所以不是唯一的。如通过name来定位百度输入框: find

更简单高效的HTML数据提取-Xpath

妖精的绣舞 提交于 2020-03-18 11:52:09
XPath 是一门在 XML 文档中查找信息的语言。XPath 用于在 XML 文档中通过元素和属性进行导航。 相比于 BeautifulSoup , Xpath 在提取数据时会更加的方便。 安装 在Python中很多库都有提供 Xpath 的功能,但是最基本的还是 lxml 这个库,效率最高。在之前 BeautifulSoup 章节中我们也介绍到了 lxml 是如何安装的。 pip install lxml 语法 XPath 使用路径表达式在 XML 文档中选取节点。节点是通过沿着路径或者 step 来选取的。 我们将用以下的HTML文档来进行演示: html_doc = '''<html> ​ <head></head> ​ <body> <bookstore> ​ <book category="COOKING"> <title lang="en">Everyday Italian</title> <author>Giada De Laurentiis</author> <year>2005</year> <price>30.00</price> </book> ​ <book category="CHILDREN"> <title lang="en">Harry Potter</title> <author>J K. Rowling</author> <year>2005<

xpath的contains用法干货

独自空忆成欢 提交于 2020-03-17 18:24:49
xpath(’//div[contains(@class,“a”) and contains(@class,“b”)]’) #它会取class含有有a和b的元素 xpath(’//div[contains(@class,“a”) or contains(@class,“b”)]’) #它会取class 含有 a 或者 b满足时,或者同时满足时的元素 starts-with 顾名思义,匹配一个属性开始位置的关键字 contains 匹配一个属性值中包含的字符串 text() 匹配的是显示文本信息, 此处也可以用来做定位用eg//input[starts-with(@name,‘name1’)] 查找name属性中开始位置包含’name1’关键字的页面元素 //input[contains(@name,‘na’)] 查找name属性中包含na关键字的页面元素 百度搜索 xpath写法为 //a[text()=‘百度搜索’] 或者 //a[contains(text(),“百度搜索”)] 原文链接:https://blog.csdn.net/qq_35810838/article/details/87886597 来源: CSDN 作者: Worldsion 链接: https://blog.csdn.net/Worldsion/article/details/104920156