Web Scraping Google-Sheets ImportXML - xpath - specific Number in URL - google-sheets

I am trying to get a specific Number from an URL, which is hyperlinked on the website.
Please see here a copy of my spreadsheet.
In Row "I" - i did a code, so it will directly go the the search of the eBay website, and combines the EAN number ="https://www.ebay.de/sch/i.html?_from=R40&_trksid=m570.l1313&_nkw="&""&D2
this is the outcome:
https://www.ebay.de/sch/i.html?_from=R40&_trksid=m570.l1313&_nkw=8713439712292
Till here it works.
On the page, i want the ebay Kategorie ID for that articel, which can be found as a Hyperlink on the Categories [See Image of eBay Categorie here] Navigation on the left.
In the URl it is always the first Number, eg. https://www.ebay.de/sch/**158817**/i.html?_from=R40&_nkw=650135421227
InspectCode URL I need
All I want know, is to put the Number 158817 in my google spreadsheet.
With this code
=IMPORTXML(I2;"//*[#id='x-refine__group__0']/ul/li/ul/li/ul")
I only get the categorie name, but I need the number to make my CSV upload work.
What code do I need? Can Someone please guide me?
thank you
Lisa

With A1 = https://www.ebay.de/sch/**158817**/i.html?_from=R40&_nkw=650135421227, try this
=regexextract(IMPORTXML(A1;"//*[#id='x-refine__group__0']/ul/li/ul/li/ul/li/a/#href");"[0-9]+")
assuming that the url is always at the same position in the nomenclature
or, to get all numbers
=arrayformula(regexextract(IMPORTXML(A1;"//*[#id='x-refine__group__0']/ul/li//a/#href");"[0-9]+"))

Related

Returning value of an item price in google sheets

I'm trying add easy updating prices into a google sheet.
I need the market price from
//*[#id="app"]/div/section[2]/section/div[1]/section[3]/div/section[1]/ul/li[1]/span[2]
https://www.tcgplayer.com/product/242811/pokemon-celebrations-celebrations-elite-trainer-box?Language=English
I need it to display just the one number from the XPath to a cell, and I can't seem to figure out where I am going wrong. I've been using the IMPORTXML function and it won't return a value.
=IMPORTXML(A2,"//*[#id='app']/div/section[2]/section/div[1]/section[3]/div/section[1]/ul/li[1]/span[2]")
where A2 is the URL.
In your situation, it seems that the value of the market price cannot be directly retrieved from the URL of https://www.tcgplayer.com/product/242811/pokemon-celebrations-celebrations-elite-trainer-box?Language=English. But, fortunately, it seems that that value can be directly retrieved from the endpoint of API. So, how about the following sample formula?
Sample formula:
=REGEXEXTRACT(JOIN(",",IMPORTDATA(A1)),"marketPrice:(.+?),")*1
or
=REGEXEXTRACT(QUERY(TRANSPOSE(IMPORTDATA(A1)),"WHERE Col1 matches 'marketPrice.+'"),"marketPrice:(.+)")*1
The cell "A1" has the URL of https://mpapi.tcgplayer.com/v2/product/242811/details.
In the case of https://www.tcgplayer.com/product/242811/pokemon-celebrations-celebrations-elite-trainer-box?Language=English, please use 242811 from the URL to the endpoint of API like https://mpapi.tcgplayer.com/v2/product/242811/details.
Result:
Note:
The value from the URL is JSON data. In this case, the following custom function can be also used. In this case, please copy and paste the following script to the script editor of Spreadsheet and save the script. And please put a custom function of =SAMPLE("url") to a cell.
const SAMPLE = url => JSON.parse(UrlFetchApp.fetch(url).getContentText()).marketPrice;
References:
IMPORTDATA
REGEXEXTRACT
Custom Functions in Google Sheets
it's not possible to scrape JS content into google sheets:

Google Sheets - How to concatenate a range based on a matching value in another cell?

I have a sheet that lists through filenames of an image gallery. Each row represents a new image; has a unique filename, but has an associated non-unique page title, as follows:
title
filename
Page 1
img1.jpg
Page 1
img2.jpg
Page 1
img3.jpg
Page 2
img4.jpg
Page 2
img5.jpg
Page 2
img6.jpg
What I need to do is concatenate each file name into a single cell, (formatted in a particular way), as follows:
title
filename
Page 1
img1.jpg///img2.jpg///img3.jpg///
Page 2
img4.jpg///img5.jpg///img6.jpg///
I have tried everything I can think of using COUNTIF, UNIQUE but I can't seem to get anywhere.
I would just write a basic formula for if A1 = "Page 1"... but I have thousands of rows to do so it would take me days and days to write them all out manually changing the formula.
Oh wise wizards of Stackoverflow, please work your wizened magic and help me out with a formula? I have no idea how to use VBA but am willing to poke around if necessary.
Many many thank-yous!
Assuming the datarange in A2:B, try
=arrayformula({unique(A2:A), trim(transpose(query(if((transpose(unique(A2:A))=A2:A)*len(A2:A), B2:B&"///",),,50000)))})
Change range to suit and see if that works?
If you don't want to have any spaces in the output, try
=arrayformula({unique(A2:A), substitute(trim(transpose(query(if((transpose(unique(A2:A))=A2:A)*len(A2:A), B2:B&"///",),,50000)))," ",)})

How to extract SEVRAL URLs from 1 Google Sheets field that are NOT formatted as hyperlinks

I have a problem extracting several URLs from a field in Google sheets and have them displayd in the next columns automatically. The field is a regular text field and the links are in that field as you may see here (not formatted as hyperlinks):
https://docs.google.com/spreadsheets/d/1VYGEHO7FIQU6mjZ-ltJJcWAIjpni6cmbxZGuKSznKbo/edit?usp=sharing
I am trying to get some automation working and would need the URLs to be displayd in separate columns with a formula or script withthe results being as I put manually in my example file...
Hope someone can help me solve this :)
Thank you !!!
try:
=ARRAYFORMULA(TRIM(SPLIT(FLATTEN(QUERY(TRANSPOSE(IF(
REGEXREPLACE(SPLIT(A2:A3, CHAR(10)&"<>", 1)&"♦",
"^\s♦|^\.\.\.\s?♦", )="",,
REGEXREPLACE(SPLIT(A2:A3, CHAR(10)&"<>", 1)&"♦",
"^\s♦|^\.\.\.\s?♦", )&"♦")),,9^9)), "♦", 0, 1)))

Any way to fetch hyperlink of a column to another column on google spreadsheet?

I copy a list of company name from a website, each of them has its hyperlink.
But now I would like to paste the names on column B of a google spreadsheet and the link list on column C.
the sample spreadsheet shows here
Column B shows name and column C shows its link like http://.....
The =HYPERLINK function syntax are as followed
HYPERLINK(url, [link_label])
Is there any way I can make the [link_label] become link url itself?
Or is there any other way to list all the hyperlink of a sheet on a column?
The square brackets in a Google function indicate that the parameter is optional. HYPERLINK defaults to display the link itself if the [link_label] is omitted.
In other words, =HYPERLINK("www.example.com") will display as www.example.com.
See Google's documentation.

Add suffix to a decimal row (to show litres)

I'm using Eureka Forms for swift 2 and I'm trying to add a Suffix to a DecimalRow. My the reason is that in this row the user will enter the amount of litre consumed, so I would like the row to display the L at the end all the time
I did not find anything in the API docs to help me with this....
Thanks

Resources