Displaying values from a Google spreadsheet on a WordPress page - wordpress

I have followed the tutorial on this website https://www.wp-tweaks.com/display-a-single-cell-from-google-sheets-wordpress/ which allows to dynamically display values from a Google spreadsheet on a WordPress page using a simple shortcode:
[get_sheet_value location="Cell Location"]
This solution worked seamlessly until a single page contained hundreds of those shortcodes (I basically need the whole content of the page to be editable via the spreadsheet). I started getting 100% Errors by API method (based on the Google Metrics) and the content was not displayed properly anymore. I realize that sending hundreds of read requests after each page load is not ideal and will inevitably affect the load performance and that Google imposes quota limits too. Is there a way to bypass this issue? For example by pulling the values from the Google spreadsheet only once a day. Unfortunately, I don't have much coding experience but I'm open to all solutions.
Thanks in advance!

You could publish the sheet to the web and embed it to your website:
In your sheet, go to File > Publish to the web
In the window that appears, click Embed.
Click Publish.
Copy the code in the text box and paste it into your site.
To show or hide parts of the spreadsheet, edit the HTML on your site.
It would look like this (click on Run code snippet):
<iframe src="https://docs.google.com/spreadsheets/d/e/2PACX-1vR3UbHTtAkR8TGNtXU3o4hzkVVhSwhnckMp7tQVCl1Fds3AnU5WoUJZxTfJBZgcpBP0VqTJ9n_ptk6J/pubhtml?gid=1223818634&single=true&widget=true&headers=false"></iframe>

You could try reading the entire spreadsheet as a JSON file and parse it within your code.
https://www.freecodecamp.org/news/cjn-google-sheets-as-json-endpoint/

Related

Embed google doc without publishing

I would like to embed a Google Slides presentation with an iframe. Anyone with the link can view it but I do not want to publish it to the web.
The "Publish to the web" option is specifically meant to embed the presentation within iframes so anyone with the link can view it, and it also gives you the iframe code, but I'm guessing that by "do not want to publish it to the web" you mean that you don't want the file to be indexed in Google searches.
According to this support thread to avoid getting indexed you can click the "Share" button and set the sharing option to "Anyone with the link":
Then to embed it within an iframe get the sharing link and replace /edit with /embed to it at the end. Example: https://docs.google.com/presentation/d/<Slide_ID>/embed.
The result looks the same as getting the "published" link, but it's not indexed by Google Search. Of course, keep in mind that it may still be found if the website where you embedded it is indexed.

How to Scrape data from Indiegogo.com in google sheets via IMPORTXML formula

I am trying to take a funding number from Indiegogo.com via IMPORTXML function without any luck.
I have used this code to scrape data from Kickstarter and it worked.
=IMPORTXML("https://www.kickstarter.com/projects/pavlyukovskyy/lego-compatible-screenless-coding-for-ages-3-6", "//span[#class='ksr-green-500']")
However, it doesn't work for indiegogo.com. I am trying this for indiegogo:
=IMPORTXML(https://www.indiegogo.com/projects/zlight-smart-bedroom-hub/", "//span[#class='data-v-3acff91c']")
I've also tried
=IMPORTXML(https://www.indiegogo.com/projects/zlight-smart-bedroom-hub/", "//span[#class='basicsGoalProgress-amountSold']")
Both versions didn't give any result
I need to show funding sum in google sheets.
Please see the screenshot https://www.screencast.com/t/h2ZwVsXr33
Here is the URL https://www.indiegogo.com/projects/zlight-smart-bedroom-hub
Unfortunately you can't scrape data from that page using importxml function because the content on the page is rendered using javascript and importxml can't import javascript rendered webpages.
Easy way to check whether a web content is rendered via javascript is to deactivate javascript. So the data which you get after deactivating javascript is the data which you can import in Google Sheet using importxml.
To Deactivate Javascript on some specific page.
Open that webpage in Google Chrome.
In the address bar, before web address, you will see an icon (lock or i etc), click on that then click on site settings and then in "Permissions" section, select "block" option for javascript.
After that simply refresh the page.

Extracting content data from webpages

I'm looking to get structured article data from webpage urls. So far I've found these two services http://www.diffbot.com/ and http://embed.ly/extract/demos/nlp. Are there better alternatives or is it worthwhile to write the code to do this myself?
If you'd like to skip the code, and are looking for a simple software for web scraping / ETL applications, I'd suggest Foxtrot. It's easy enough to use and doesn't require coding. I use it to scrape data from certain gov't websites and dump it into an Excel spreadsheet for reporting purposes.
I have done web scraping / content extract for quite some time now.
For me the best approach is to write a Chrome content extension and automate the browser with their API. This requires that you know Javascript and HTML. In one of my recent projects I use a background page with a couple of editable divs to configure the scraping session. I have some buttons on the background page to start the process. The background page loads a JS script which listens to click events of the buttons.
When one of the buttons is clicked I add a new tab for the scraping session with chrome.tab.create. The background js also defines some chrome.tabs.onUpdated.addListener to inject content scripts when the tab url contains a specific page/domain name.
The content script then does the scraping job for example selecting some elements with jquery, regular expressions etc and finally send a message with an object back to background JS using chrome.runtime.sendmessage. The background JS script listens to messages with chrome.runtime.onMessage.addListener and acts based on the content being extracted.
The extension also automates web databases by clicking for example the next page links.
I have added a timing setting to control the amount of links being clicked / tabs being opened per minute so that the access is slowed down on purpose and too much crawling is avoided.
Finally the results are being uploaded to a database with an AJAX call and inserted with a PHP page into MySQL.
When the extension runs the next time it compares the keys/links which already exist in the database with another AJAX call and ensures that only new information is being extracted.
I have also built extension like the above with Firefox but the best and easiest solution for me is a Chrome/Chromium content extension.

How do I embed code to appear on every product page in shopify?

I am trying to add some Google Analytics related code (addition to the standard code) on every product page. I tried adding it to the bottom of the "product.liquid" file but it doesn't seem to pull through to the live site. Could it be to do with some special Shopify security function that stops unusual looking javascript from being used?
Kind regards,
Benet Hitchcock.
Yes you can do this through your app. You need to take read|write_theme scope at the time of installation of you app now go to theme setting->temeplate editor
Open themes.liquid file and paste your code there
Then its appears on all page

Can google see the contents of an iframe when spidering?

I've looked this up and have not found consistent answers. I want to embed a google doc in my page (when you publish your google doc it gives you an iframe). Will search engines like google be able to read the contents of the document (just text, but may have important keywords)? Or will it act as if the page was empty?
If it cannot index the text then is there any way to have the embed in some sort of server side include so that it appears to be hard-coded into the html to spiders?
No, they will not read it and assosiate the content to your site. They will eventually crawl it sometime but it will not be associated as "your" content.
Only way to do it, is to write server side code that scrapes the content and outputs it inside your page.
Right now, the page looks empty to the search engines.
I am not so sure that they can't since you can start seeing iframe content being rendered in the site previews under Google Search i.e. any facebook page tab application can be seen now and they all work through iframes

Resources