xpath

How to match <sup>value</sup> in XSL-FO

此生再无相见时 提交于 2020-03-06 04:09:15
问题 I'm using xsl-fo and trying to style xref content within a <sup> eg I want to make the 2 superscript. <sup id="FNB-0002"><xref href="#Comp_CLJONLINE_CLJ_2010_04_2/FN-0002">2</xref></sup> I am using the following code which I think should work. <xsl:template match="sup[@id='*']"> <fo:inline font-size="24pt" font-weight="bold" text-indent="2em" text-transform="uppercase" > <xsl:apply-templates/> </fo:inline> </xsl:template> But none of the styles I am applying are being recognised. I'm

Google spreadsheet importxml : how to grab all names of element nodes in XML

丶灬走出姿态 提交于 2020-03-06 03:09:54
问题 I'm trying to use importxml function to import XML. <item> <name>James</name> <date>11/11/2016</date> <description>Student</description> </item> If I use, =importxml(URL, "//item") I can import the information, but not the names of each information. I'd like to pull something like this name date description James 11/11/2016 Student Any xPath function to do this? 回答1: You can get the headers with this formula: =unique(arrayformula(regexreplace(transpose(split(IMPORTDATA(A1),"><",false)),">.*|\

Google spreadsheet importxml : how to grab all names of element nodes in XML

谁都会走 提交于 2020-03-06 03:08:02
问题 I'm trying to use importxml function to import XML. <item> <name>James</name> <date>11/11/2016</date> <description>Student</description> </item> If I use, =importxml(URL, "//item") I can import the information, but not the names of each information. I'd like to pull something like this name date description James 11/11/2016 Student Any xPath function to do this? 回答1: You can get the headers with this formula: =unique(arrayformula(regexreplace(transpose(split(IMPORTDATA(A1),"><",false)),">.*|\

python爬虫教程: Python利用Scrapy框架爬取豆瓣电影示例

笑着哭i 提交于 2020-03-06 02:15:43
本文实例讲述了Python利用Scrapy框架爬取豆瓣电影。分享给大家供大家参考,具体如下: 1、概念 Scrapy是一个为了爬取网站数据,提取结构性数据而编写的应用框架。 可以应用在包括数据挖掘,信息处理或存储历史数据等一系列的程序中。 通过Python包管理工具可以很便捷地对scrapy进行安装,如果在安装中报错提示缺少依赖的包,那就通过pip安装所缺的包 pip install scrapy scrapy的组成结构如下图所示 引擎Scrapy Engine,用于中转调度其他部分的信号和数据传递 调度器Scheduler,一个存储Request的队列,引擎将请求的连接发送给Scheduler,它将请求进行排队,但引擎需要时再将队列中的第一个请求发送给引擎 下载器Downloader,引擎将请求Request链接发送给Downloader之后它就从互联网上下载相应的数据,并将返回的数据Responses交给引擎 爬虫Spiders,引擎将下载的Responses数据交给Spiders进行解析,提取我们需要的网页信息。如果在解析中发现有新的所需要的url连接,Spiders会将链接交给引擎存入调度器 管道Item Pipline,爬虫会将页面中的数据通过引擎交给管道做进一步处理,进行过滤、存储等操作 下载中间件Downloader Middlewares,自定义扩展组件

JSONPath - 用于JSON的XPath

本小妞迷上赌 提交于 2020-03-05 13:35:52
XML 经常被强调的优点 是可以使用大量工具来分析,转换和有选择地从XML文档中提取数据。 XPath 是这些强大的工具之一。 现在是时候想知道,如果需要像XPath4JSON这样的东西,它可以解决的问题是什么。 可以 在客户端上以 JSON 结构 交互式地找到和提取数据,而 无需特殊脚本。 客户端请求的JSON数据可以减少到服务器上的相关部分,例如最小化服务器响应的带宽使用。 如果我们同意,那么从手边的JSON结构中挑选零件的工具确实有意义,就会出现一些问题。 它应该如何完成它的工作? JSONPath表达式如何? 由于JSON是C系列编程语言数据的自然表示,因此特定语言具有访问JSON结构的本机语法元素的可能性很高。 以下XPath表达式 /store/book[1]/title 看起来像 x.store.book[0].title 要么 x['store']['book'][0]['title'] 在Javascript,Python和PHP中使用包含 x JSON结构 的变量 。 在这里我们观察到,特定语言通常具有内置的基本XPath功能。 有问题的JSONPath工具应该...... 自然地基于那些语言特征。 仅涵盖XPath 1.0的基本部分。 代码大小和内存消耗都很轻松。 运行效率高。 | 2007-08-17 | e2 # JSONPath表达式

python爬虫----XPath

梦想与她 提交于 2020-03-05 13:35:38
1.知道本节点元素,如何定位到兄弟元素 详情见 博客 XML代码见下 bt1在文档中只出现一次,所以很容易获取到bt1中内容,那怎么根据<td class='bt1'>来获取bt2中的内容 content_title = driver.find_element_by_xpath("//td[@class='bt1']").text # 获取content_title的父节点的哥哥节点 content_subtitle = driver.find_element_by_xpath("//td[@class='bt1']/../following-sibling::tr[1]").text # 获取第二个tr下面td的父节点的弟弟节点 conten_subtitle = driver.find_element_by_xpath("//td[@class='bt1']/../preceding-sibling::tr[1]").text  返回的内容为:高起点高水平推进福州新区建设 尤权于伟国赴福州新区调研 ‘’ 2.元素替换,查找元素位置可以用变量替换字符串 >>> driver.find_element_by_xpath("//*[@id='mp1057136']").click() >>> a='mp1057136' >>> driver.find_element_by_xpath

爬虫项目1[爬取小猪短租数据]

房东的猫 提交于 2020-03-05 07:02:28
看了这个大神的博客— 爬虫项目合集 ,自己也动手实践一下 请求:requests 解析:xpath 思路:找到起始网页(第一页),爬取初识网页的数据,获取下一页的链接,爬取下一页的数据,以此类推 非常简单,直接放代码: import requests from lxml import etree source_url = "http://bj.xiaozhu.com/" # 以北京地区为例 headers = { "user-agent" : "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.106 Safari/537.36" , "referer" : "http://bj.xiaozhu.com/" } # 请求头比较简单,如果被识别可以换为更复杂的(多加几个字段) data_lst = [ ] # 这里用list和dict简单存一下,最好存到数据库中(以后会用mysql) def request ( url ) : response = requests . get ( source_url , headers = headers ) . content return response def get_data ( text )

Can I add the id property to an html element created with React

心已入冬 提交于 2020-03-05 04:15:07
问题 I'm using Selenium to write end-to-end tests for a web application developed in React. Upon inspecting the website I found out that practically none of the html elements have the id property set. As our dev team is busy doing other things I'm supposed to resolve this myself. I've worked around this issue so far by using css selectors and xpath to locate elements in my tests. However, I feel like this method is prone to errors and since I'm not particularly involved in the dev proccess I might

python+selenium对元素进行截图以及截图产生偏差问题

佐手、 提交于 2020-03-04 18:11:07
原理: 1.截图(整个窗口) 2.获取此元素坐标 element = driver.find_element_by_id("xx") element.location) 3.获取此元素大小 element = driver.find_element_by_id("xx") element.size 4.根据元素坐标和元素大小确定此元素四个角坐标 5.依赖pillow,根据四角坐标crop((left, top, right, bottom)裁剪图片并保存 #! /usr/local/bin/python3 #coding=utf-8 import os,execjs from PIL import Image from time import sleep from io import BytesIO from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys from selenium.webdriver.support.select import Select # 引入下拉框操作的类模块 from selenium.webdriver.support.wait import

scrapy入门(一)

只谈情不闲聊 提交于 2020-03-04 00:17:10
scrapy入门 一. Terminal命令 创建爬虫项目 scrapy startproject spider_project_name #自定义项目名 spiders文件夹中创建爬虫源文件, 也是爬虫主要功能实现的部分 cd spider_project_name #进入项目 scrapy genspider spider_name www.baidu.com #spider_name 新建的爬虫名 #www.baidu.com 域名 #规则爬虫:scrapy genspider -t crawl xxx(爬虫名) xxx.com (爬取域) 运行命令:scrapy crawl spider_name或scrapy crawl xxx -o xxx.json 二. 各文件配置及其作用 settings 文件 项目的配置文件 需要修改的地方有: 19行 : USER_AGENT 修改robots协议为ROBOTSTXT_OBEY = False 添加控制输出日志的语句 : LOG_LEVEL = 'ERROR' 和LOG_FILE = 'log.txt' 67行取消注释, 启用管道存储 ITEM_PIPELINES items文件, item对象用来保存文件 需要在item文件中定义属性 例如爬取虎牙直播的各个主播的标题, 主播名, 人气 title = scrapy.Field