This question already has answers here:
Scraping data to Google Sheets from a website that uses JavaScript
(2 answers)
Closed last month.
I've used ImportHTML plenty of times before and never really had any issues with it, but for some reason, I can't seem to pull a particular table from Basketball-Reference, even though I've pulled other tables from there just fine. The table I want is the Miscellaneous Stats table lower down on this page. I've tried every index from 1 to 30 in the function, but none of them past 7 bring in any data. The function I'm using is below, with the 1 changing to whatever index I'm trying:
=IMPORTHTML("https://www.basketball-reference.com/leagues/NBA_2019.html", "table", 1)
I tried using the following code in Chrome's console to find the index of the page, but it didn't return anything:
var i = 1; [].forEach.call(document.getElementsByTagName("table"), function(x) { console.log(i++, x); });
Does anyone know how I can get this table working with ImportHTML?
Well, player0 was correct about being unable to scrape the JS table, but luckily I was able to use the URL for the embed version of that table, which works perfectly with ImportHTML.
Related
I came across an interesting way to combine CSE (Custom Search Engine) and PSE (Programmable Search Engine) and use it as a function in Sheets using the following AppScripts code:
Article Link Credits < the great Giacomo Melzi >
Code <
Now , on passing '0' as the value for 'index' parameter, the results are displayed vertically.
Can anyone change it to display the results horizontally across the same row using some code in Google App Script?
I expect someone to answer this soon, Thanks!
You should be able to do it with =TRANSPOSE(LINKEDINPROFILE(A3,0))
This question already has answers here:
Getting the document of external url with javascript
(1 answer)
Get the source DOM/HTML of an external page from URL
(1 answer)
Closed 6 months ago.
I want to Scarpe the number of problems I have solved across all the coding platforms.
The approach I went for is to go to the profile URL of each of these platforms and then, get the number of problems solved displayed there.
For leetcode it is defined by the class name below, and I have check it works using console.
Now the problem is, I have no idea how to use this document.getElementByClassName on an external website.
var url='https://leetcode.com/profileID/';
var elements = document.getElementsByClassName("text-[24px] font-medium text-label-1 dark:text-dark-label-1")[0].innerText;
console.log(elements);
}
I try and it worked
var elements = document.getElementsByClassName("text-[24px] font-medium text-label-1 dark:text-dark-label-1")[0].textContent.trim();
I'm currently trying to return the FIRST* image displayed on a webpage with code:
img.src = chrome.extension.getBackgroundPage().imageSrc[0]
0 represents the first image. This seems to work. However, the getBackgroundPage() is only functional with the tab currently opened. I want this to work even if the user is using a different webpage.
In discovering how to find the first image of a website that ISn't currently runnning, I first have to understand what chrome.extension.getBackgroundPage() returns. Is it a string? Or a url?
I've tried replacing this with,
[document.getelementId("hi").getsrc.]imageSRC[0]...hi is represented in htm as as a div with src of a url that I want...But it does not work. Any solutions?
Why are you trying to use an extension to do this?
Try this;
document.getElementsByTagName('img')[0];
This is vanilla javascript and needs no plugins, extensions or particular browsers.
EDIT
To answer your question;
Returns the JavaScript 'window' object for the background page running inside the current extension. Returns null if the extension has no background page.
Thats according to the docs.
EDIT 2
Ok, so, chrome.extension.getBackgroundPage() returns the 'window' object, which means you may be able to do this;
w = chrome.extension.getBackgroundPage()
w.document.getElementsByTagName('img')[0];
EDIT 3
Once you have a dom object, you can get any attributes like so;
document.getElementsByTagName('img')[0].src;
EDIT 4
Apologies for not understanding initially. Have a look at the source for the 'BitBucket Notifier' extension on chrome. Most importantly this file.
It polls Bitbucket every 5 seconds (if I'm reading it correctly) and returns data from the site for the extension.
Could this be used in your extension?
I have to load same html page with in colorbox but with different Query string parameters. Everything is working fine except JQuery. i.e. the count of some specific divs, I am using $('div').length; and it is returning the wrong output which is the sum of last opened colorbox and currently opened.
Your going to have to be more specific when your asking for help in Q/A site. Even if your English is not perfect more information about the problem your facing will help us help you. I'm going to try my best to make sense of what your asking :
I have to load same html page that uses a colorbox but with different
Query string parameters.
What color box library, tool or script are you using?
Everything is working fine except JQuery.
I assume your having a problem with a jQuery command.
The count of some specific divs, I am using $('div').length; and it is
returning the wrong output
What is the expected output?
which is the sum of last opened colorbox
and currently opened.
I'm not sure what you meant by that statement.
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
How can I update the title of the tab in the same way GMail/Facebook does?
How is it possible to update my browser title value, like Facebook and Yahoo, to show a number that represents notifications/pending items/new messages etc.
Right now, my Facebook page title/tab reads [ (3) Facebook ], which indicates I have 3 unread notifications.
How is this possible? I reckon it uses JS and AJAX but I maybe wrong. Has anybody got any snippets, links or suggestions that will get me started in this?
It's a really nice feature but don't seem to find many websites using it, neither can I find any decent tutorials or examples.
Many thanks
It's just a property of the document object
document.title = "some string";
Use whatever logic you like to determine what information you want to put in there.
Be aware that it will produce some really odd bookmark names.
You just need to change title of your page using javascript.
if you are using jquery, it is as simple as -
$('title').text('someText (3)')