I am using google documents API. I need to implement pagination.
I used like below.
First page:
qry.setMaxResults(10);
qry.setStartIndex(1);
Second page:
qry.setMaxResults(10);
qry.setStartIndex(11);
I am getting same 10 results for second page also.
This question has this as answer link.
I am unable to find any answer in this link.
Can any one help me?
Thanks in advance..
The Documents List API uses "next" tokens for pagination and not the start index:
https://developers.google.com/google-apps/documents-list/#getting_all_pages_of_documents_and_files
To retrieve all pages of documents, you start from the beginning and then follow the link with rel=next to get more pages.
The max results parameter is used to limit the number of elements in each page.
Remember you can (and should) also use the newer Drive API to perform the same task:
https://developers.google.com/drive/v2/reference/files/list
Related
I'm trying to create a Google Apps Script that pulls a specific value from this webpage https://www.luno.com/en/price/XRP. I'm attempting to read the HTML to find the value that I'm looking for which the price of XRP from my broker, denoted as "MYR". Here's the code I'm trying to use.
function getXRP(){
var html = UrlFetchApp.fetch('https://www.luno.com/en/price/XRP').getContentText();
var loc = html.indexOf("MYR");
return html.substring(loc, loc+8);
}
From what I understand, html.indexof("MYR") is returning a value of 0, hence the output I'm getting is the first 8 characters of the websites XML
<!DOCTY
For reference, I'm trying to capture the price as below and insert it into my Google Sheets document. Any help would be greatly appreciated, Thank you!
html.indexOf("MYR") is returning -1 because the source code of the page that you are fetching doesn't include MYR.
UrlFetchApp.fetch('https://www.luno.com/en/price/XRP').getContentText() can't be used to fetch dynamic content, instead you should find some way to create a headless browser and parse the rendered DOM instead of the source code.
Related
Using Apps Script to scrape javascript rendered web page
Is it possible to use Google Apps Script to get an info from the code I see at DevTools?
You can just use their API service and fetch the price: https://www.luno.com/en/developers/api#tag/Conventions
It'll be less overhead to fetch from a API than to scarp the whole webpage, parse the field by ID or name and then insert it into the spreadsheet. Fetching from API is lot easier and resource friendly.
This is a question most suitable for Youtube API developers.
Having 2 queries performed to get the videoid and the title (first query)
https://www.googleapis.com/youtube/v3/search?safeSearch=moderate&order=relevance&part=snippet&q=".urlencode($q). "&maxResults=10&key=". $api;
and a second query to get the contentDetails to see if the video is licensed or not
https://www.googleapis.com/youtube/v3/videos?part=contentDetails&maxResults=10&id=".$vid."&key=". $api;
I was expecting the Google dashboard to show 2 queries, instead it shows a 4 queries.
I'd like a clue as to how google counts this searches. Anybody has checked this behaviour?
I want to clear something regarding your issue. If your API requests returns multiple pages of results, this will add to the query as stated from here.
Note: If your application calls a method, such as search.list, that
returns multiple pages of results, each request to retrieve an
additional page of results will incur the estimated quota cost.
It is due to requesting again a token for another result per page. You can also check the Youtube Quota Calculator documentation for more details.
If this is not the case, this can be a bug. You can try to log the issue here.
I'm trying to build a super simple Google Sheet dashboard comparing the prices at D+7 and D+30 in real-time of specific listings/rooms that are both on Airbnb and Booking.com.
On the Booking.com side, it was super easy : I just created a formula concatenating the URL with the check-in/check-out dates, number of guests and trip duration as parameters and using the =IMPORTXML function and the proper class, I was able to automatically retrieve the price.
It is more difficult on Airbnb, as the price is dynamic(see here: https://www.airbnb.com/rooms/25961741). When I use what I think is the proper class, I get a "N/A Error, Imported content is empty" on Google Sheet.
I also tried using the Airbnb API with REGEX functions to extract the price, but the price set in the listing info is a default price, and does not reflect reality:
"price":1160,"price_formatted":"$1160"
https://api.airbnb.com/v2/listings/25961741?client_id=d306zoyjsyarp7ifhu67rjxn52tv0t20&_format=v1_legacy_for_p3&number_of_guests=1
Do you now if there are any other possible way to access this dynamic price and have it automatically parsed into a spreadsheet? It seems that the data I'm looking for in within meta tags on the HTML code and I don't know if it's possible to scrape it into Google sheet using =IMPORT functions.
Maybe with of a script ?
Thanks a lot !
I'm curious if you were unable to yank direct with the ABNB API; what if you tried to directly pull off the site's service? Have a look at this URL:
https://www.airbnb.com/api/v2/explore_tabs?version=1.3.9&satori_version=1.0.7&_format=for_explore_search_web&experiences_per_grid=20&items_per_grid=18&guidebooks_per_grid=20&auto_ib=false&fetch_filters=true&has_zero_guest_treatment=false&is_guided_search=true&is_new_cards_experiment=true&luxury_pre_launch=false&query_understanding_enabled=true&show_groupings=true&supports_for_you_v3=true&timezone_offset=-240&client_session_id=8e7179a2-44ab-4cf3-8fb8-5cfcece2145d&metadata_only=false&is_standard_search=true&refinement_paths%5B%5D=%2Fhomes&selected_tab_id=home_tab&checkin=2018-09-15&checkout=2018-09-27&adults=1&children=0&infants=0&click_referer=t%3ASEE_ALL%7Csid%3A61218f59-cb20-41c0-80a1-55c51dc4f521%7Cst%3ALANDING_PAGE_MARQUEE&allow_override%5B%5D=&price_min=16&federated_search_session_id=5a07b98f-78b2-4cf9-a671-cd229548aab3&screen_size=medium&query=Paris%2C%20France&_intents=p1&key=d306zoyjsyarp7ifhu67rjxn52tv0t20¤cy=USD&locale=en
This is a GET request to ABNB's live page search; now I don't know much about ABNB but I can see from the listings portion of the JSON feed it does have a few pricing factors that differ from the API results you provided; I'm not sure what you need to pull exactly but this may lead you in the right direction; check the 'Listings' array and see if there's something you can possibly use.
Keep in mind if you are looking to automate scraping this data you would want to generate new search sessions; but first you want to see if this is the type of data you're looking for.
Another option, Google CSE's API; I've pulled data in the page headers of sites as they appear in Google based on the Schema.org's tags; but this may be delayed data and it appears you need real-time; the best route would be reserach the above example or try to make sure of ABNB's natural API (they provide its functionality for a reason right?; there must be a way to get what you need).
Hope my answer helped lead you in the right direction!
Do we have a way to identify who created the page (Created by in Get pages request) using API call? We see the properties Created By and last Modified By for Get sections. Can we get the same properties for Get pages?
Currently the OneNote GET ~/pages API does not support the properties "CreatedBy" and "LastModifiedBy. I would recommend creating an item in UserVoice (I will upvote it ;) )
https://onenote.uservoice.com/forums/245490-onenote-developer-apis
Hi I'm working on an Arduino project and I'd like to display the next event from a Google calendar on a small display. I want to know if there's a way to limit the size of a HTML request from Google. Right now when I do the request I'm getting my full calendar's data. This significantly slows down the time it takes to get the event. I tried using a GET request and Range bytes 1000-3000 but this doesn't seem to work. Does anyone know any workarounds for this without going through Oauth?
You want the "maxResults" parameter and you may also like to limit the fields returned using the "fields" parameter as well. Check the events > list docs for details.