I would like to get both the url and text, "http://example.com" and
"reference".
First, access to the page that contains this link.
doc = Nokogiri::HTML(open(url))
then,
name = doc.xpath('//div.../a').text
url = doc.xpath('//div.../a/@href).text
It works. But the problem is this is parsing twice separately.
If you want to apply the same procedure to many links that exist in a
single page, it seems inefficient.
Is there anyway to produce both url and text by single parse? like
I would like to get both the url and text, "http://example.com" and
"reference".
First, access to the page that contains this link.
doc = Nokogiri::HTML(open(url))
then,
name = doc.xpath('//div.../a').text
url = doc.xpath('//div.../a/@href).text
It works. But the problem is this is parsing twice separately.
If you want to apply the same procedure to many links that exist in a
single page, it seems inefficient.
Is there anyway to produce both url and text by single parse? like
I would like to get both the url and text, "http://example.com" and
"reference".
First, access to the page that contains this link.
doc = Nokogiri::HTML(open(url))
then,
name = doc.xpath('//div.../a').text
url = doc.xpath('//div.../a/@href).text
It works. But the problem is this is parsing twice separately.
If you want to apply the same procedure to many links that exist in a
single page, it seems inefficient.
Is there anyway to produce both url and text by single parse? like