[英]Extract attribute value using css selectors
From the below HTML I am looking to extract the link in 'data-url' by using CSS selectors only(No methods).从下面的 HTML 中,我希望仅使用 CSS 选择器(无方法)提取“data-url”中的链接。
<a class="btn" data-url="https://example.com">
BTW, I am trying to scrape a website using a _ scraper tool called webscraper .io, where the data to be extracted has to be specified using a CSS selector.顺便说一句,我试图用所谓的webscraper .IO一_刮刀工具,要被提取的数据已经使用一个CSS选择器被指定为刮网站。 Hence, I cannot make use of any useful methods from other programming languages.
因此,我无法使用其他编程语言中的任何有用方法。
The only thing I can think of is this:我唯一能想到的是:
.btn::after {
content: ' ' attr(data-url);
}
Working Example:工作示例:
.btn::after { content: ' ' attr(data-url); }
<a class="btn" data-url="https://example.com">URL:</a>
You can extract the url from the tag by using Element Attribute & then specifying the attribute name data-url
in the attribute name field.您可以使用元素属性从标签中提取 url,然后在属性名称字段中指定属性名称
data-url
。
You can refer to the following sitemap for your reference.您可以参考以下站点地图以供参考。
{"_id":"stack-sample","startUrl":["http://elitesolution.co.in/sample/inde.html"],"selectors":[{"id":"a parent","type":"SelectorElementAttribute","parentSelectors":["_root"],"selector":"a","multiple":false,"extractAttribute":"data-url","delay":0}]}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.