Can't get XPath code right in Google Spreadsheet - html

I'd start by saying that I have very little knowledge (sadly) of HTML since I do not work in IT. Anyways, I am trying to get the Google Spreadsheet to display data from this website:
http://www.oddsportal.com/soccer/england/premier-league/results/#/page/2/
I would like to display data from the central table, where results and odds are displayed. I go to Inspect and get the XPath code for this table is:
//*[#id="tournamentTable"]
But, upon typing it into the importxml function, will give me the error
=importxml("http://www.oddsportal.com/soccer/england/premier-league/results/#/page/2/"; "//*[#id="tournamentTable"]")
After reading here and there on this site, I tried editing the formula and substituting " with ' inside the query, but it gives a blank response.
Could anybody help me?
Am I redirecting the wrong XPath or did I type anything wrong inside the formula?

Related

How do I convert a dynamic coded hyperlink in excel to the equivalent HTML code?

I've found a similar question, but the answer didn't solve my issue. I'm trying to do a similar thing as this post, but I'm not sure if my original Excel cells are populated with the same thing.
Mine don't have a fixed link, but rather reference other cells using the following formula:
=HYPERLINK("https://www.website.com/search/?search="&B2, "View")
I've tried running the VBA code from the linked post above, but no luck. Is there a tweak for this to populate the resolved URL into the proper HTML code using "View" for the hyperlink text? The value in cell B2 is a number, let's say 12345.
So I'd like the end result to populate the cell with:
<a href="https://www.website.com/search/?search=12345>View</a>
End goal: I'm trying to export the Excel data as HTML table code, so trying to prepare the cells for proper HTML format to display the links on the website. Any export method I've found just exports the hyperlink cell as plain text "View" which is obviously not the desired result. If I can convert these cells before the export, then that solution would work fine.
Alternately, if there's a way to directly export the entire spreadsheet to an HTML encoded table (while also converting the hyperlinks as above), that would be even better. Note: the export to website function within Excel (using 2016) does not work...I need simple, plain HTML list code that doesn't reference the original spreadsheet.
Sorry if I've misunderstood your question, but does this help?
Function for Column B
="<a href='https://www.website.com/search/?search="&A2&"'>View</a>"

Changing number of a web page (in the URL), change the display but not the Html source code

I am facing a behavior that I really don't understand.
If you go on the webpage: https://www.edel-optics.fr/Lunettes-de-soleil.html#ful_iPageNumber=1 and inspect the code you will realize that it's the same html content as on https://www.edel-optics.fr/Lunettes-de-soleil.html#ful_iPageNumber=7
=> to test it, try to search "ERIKA - 710/T5" on both source codes and you will find it (but you should only find on the ful_iPageNumber=1).
Why is it behaving like this ?
Secondary question: how to I get the real content of https://www.edel-optics.fr/Lunettes-de-soleil.html#ful_iPageNumber=7 ?
Thank you for your help
John
Problem
You have explained that when you perform a search, you get the same results as with your pagination (page 1)
Issue
You are not getting the value your searching for placed into the URL
https://www.edel-optics.fr/Recherche.html?time=1519871844737#query=
the #query is = to nothing
You would be needing something like:
https://www.edel-optics.fr/Recherche.html?time=1519871844737#query=ERIKA%20-%20710/T5
Without seing your code its hard to say where the issue lays. it could well be that the search box is not inside the Form or it could be that the submit button is on another form to the search box, or maybe an issue with backend scripts not grabbing the get values as a result of case differences in the value name.
Without seing your script its hard to diagnose
Ok I found a solution to solve this strange problem, replace the # in the URL with a ? and you will have the actual html content (corresponding to the display)...

How to get Google search result snippets (descriptions) by using importxml function?

I want use Google spreadsheet =importxml to get Google search results snippets but I don't know what XPath I should use. Could any tell me what is XPath for it?
I tried using //h3[#class='result-desc'] but it keeps telling me:
imported content is empty
=IMPORTXML("https://www.google.com/search?q=Bmw&safe=off&tbs=qdr:d", "//h3[#class='result-desc']")
What is correct XPath for it?
Remember that Google Sheets ImportXML function will often receive a different HTML than what you see in a browser. (For example it doesn't load JavaScript, etc), so you cannot rely on inspecting HTML to get your XPATHs.
In your case some examples you can try:
=IMPORTXML("https://www.google.com/search?q=Bmw&safe=off", "//*[#class='g']")
or
=IMPORTHTML("https://www.google.com/search?q=Bmw&safe=off","list",9)

find contact us pages using google importxml xpath

I am trying to pull links to contact pages from a list of urls in column B. I have tried the following but I get an error:
=IMPORTXML(B10,"//a[contains('contact')]/#href")
I want to be able to get href value for every a element that has anchor text containing the word "contact".
Any help would be appreciated.
Without seeing the URL you import, I can only comment on the XPath expression. Your expression is not valid, contains() always takes two arguments. Use
=IMPORTXML(B10,"//a[contains(.,'contact')]/#href")
If that does not give the expected result, you have to tell us the URL of the document you are importing.

yql link list to html

I'm using yql to return a list of links from specific webpages. So far so good, it returns all the links that I pretend, however I don't know how to translate that info into my webpage.
Here's what I'm trying to do:
YQL returns a list of links in the
results
I want those links to appear in my
webpage, inside a table, inside divs,
etc... like if i wrote them there.
I have been trying to find a way to do this but I don't know much of js and json so I'm here trying to achieve some answer from those of you that might know a way.
There are a couple of ways to do this, depending on which approach you want to take.
First, and simplest, is server-side generation. This is what would result, for example, if a user hits a Submit button on a search form to send you his query, your script receives the query and generates the page, then sends that page to the user. In this case, your question is largely trivial. In pseudocode:
ASSIGN the list of results to list L
FOR EACH ITEM r IN L
PRINT a string containing an HTML template, substituting the value
r where appropriate
It's trivial enough that I suspect you want to do this via DOM manipulation. This is what requires JavaScript: you get the query, send the request without refreshing the page, and want to add the results to the DOM. If you're receiving the list of results, you're already most of the way there. Using jQuery, you would do the same thing as in the pseudocode above, except that where it has the PRINT statement you would have:
$(".SearchResults").append("<li>" + r + "</li>");
I highly recommend reading through the jQuery tutorial. It's not as hard as you think.