Check domains for content with google spreadsheet - import

I am looking for a solution in google spreadsheet to check if a domain has any content on its site or shows a blank page/brings a 404 error.
I am looking for a way to get two different outcomes (1 and 0) by these requirements:
1 if domain is existing and there is content on this domain
0 if domain is not existing
0 if domain is existing but can't be reached (404)
0 if domain is existing and can be reached but has a blank page
Examples are found in the following spreadsheet: https://docs.google.com/spreadsheets/d/1gcdF_NdhYX4vBJgwP-cAVsTmeO2WgrynND2f63Zi3Lk/edit#gid=0
I was trying to get some date from the domains with IMPORTDATA, IMPORTHTML and IMPORTXML (as a next step I would add another column that gives me 1 if content is not cell is not empty, 0 else:
=if(isna(IMPORTDATA(A1))=FALSE;1;0)
=if(isna(importhtml(A9;"list";1));"";transpose(IMPORThtml(A9;"list";1)))
=IMPORTXML(A13;"//h:h1")
But these formulas are not reliable enough to handle the task.
I'd be a big fan of IMPORTXML, but as I read so far it is currently not working in new google spreadsheets (not even the official examples are working for me...).
Is there any way to solve this problem for about 1000 domains?
Thanks in advance!

You can try creating a script in the script editor:
function SOverflowChecker( uri )
{
var response_code ;
try {
response_code = UrlFetchApp .fetch( uri ) .getResponseCode() .toString() ;
}
catch( error ) {
response_code = error .toString() .match( / returned code (ddd)./ )[1] ;
}
finally {
return response_code ;
}
}
Save it then in the cell use this code:
=SOverflowChecker(RowValueOfURL)
RowValueOfURL being the row for whatever your URL is on.
So for example if the URL is in B2:
=SOverflowChecker(B2)
It will check the website and return a status code, based on the status code you can evaluate the URL is dead or alive.
Reference:
http://www.tinkeredge.com/blog/web-usability/check-on-page-for-broken-links-with-google-docs/
Hope this helps

Related

Displaying Records with route53 using .net

Before I begin I do want to mention this is my first time doing this so forgive any errors I might do. I am currently learning how to use route53 using .net and I am currently stuck on getting it to post records in a field. I have the correct Accesskey,Secretkey and hostedzone id.
iv tested pulling up the name of the hosted zone aswell as getting it to display the number of records. but when i try to get it to actually post the values it displays: "Amazon.Route53.Model.ListResourceRecordSetsResponse". I'm sure the answer is right there in front of me but in the API for route53 there isnt really any guidelines to showing records. it shows you how to create records but not simply viewing them.
Here is what I have:
route53Client.ListResourceRecordSets(new ListResourceRecordSetsRequest
{
HostedZoneId = "HostedZoneId here",
MaxItems = "1"
});
I'm assuming that I am not including enough information for it to properly pull the records. I can pull them up through the AWS CLI so I know I have what i need to see them. just stuck on this part. any help would be great.
Here is the link to the API: https://docs.aws.amazon.com/sdkfornet/v3/apidocs/index.html
Process ListResourceRecordSetResponse like this:
var result = client.ListResourceRecordSets(
{
HostedZoneId = "HostedZoneId here",
MaxItems = "1"
});
foreach (var recordSet in result.ListResourceRecordSetsResult.ResourceRecordSets)
{
// ResourceRecordSet
foreach(var resourceRecord in recordSet.ResourceRecords)
{
// ResourceRecord
Console.WriteLine(resourceRecord.Value);
}
}
ListResourceRecordSetsResponse
ResourceRecordSet
ResourceRecord

how to solve actions on google-Api.ai error

Screenshot 2The one screen shot of this errorissue I am building an app using api.ai , an syllabus app which tells you the syllabus, but when I invoke it with desired parameters like branch and semester I have made each individual intent for it even then I'm getting miss answers sometimes like when asked for sem 4 and branch electronics its showing sem 3 sem 4 or of other branch . I have given sem and branch as required n given few invoking statements even then getting this. Tried even training it manually for free 30s of actions on api.ai no solution please help. Not using any web hook , context , event.
Short answer - check here for screenshots http://imgur.com/a/tVBlD
Long answer - You have two options
1) Create 3 separate custom entities for each branch type (computer science, civil, communication) which you need to attach to your branch parameter
2) Using the sys.any entity and attaching it to your branch parameter; then determining what the incoming parameter value is on a server then sending back a response through a webhook.
If you go the second route, you have to create a webhook and hardcode recognized words like 'computer science' in IF statements which check the incoming parameter (sent through JSON from API.AI). This route will be more difficult but I think you will have to travel it regardless because you will have backend architecture which you access to find and return the syllabus.
Note the second route is what I did to solve a similar issue.
You can also use regex to match an item in a list which limits the amount of hardcoding and if statements you have to do.
Python regex search example
baseurl = "http://mywebsite.com:9001/"
# Parse the document
# Build the URL + File Path and Parse the Document
url = baseurl + 'Data'
xmlLink = urllib.request.urlopen(url)
xmlData = etree.parse(xmlLink)
xmlLink.close()
# Find the number of elements to cycle through
numberOfElements = xmlData.xpath("count(//myData/data)")
numberOfElements = int(numberOfElements)
types = xmlData.xpath("//myData/data")
# Search the string
i = 0
while numberOfElements > i:
listSearch= types[i].text
match = re.search(parameter, listSearch, re.IGNORECASE)
if match is None:
i += 1
else:
# Grab the ID
elementID = types[i].get('id')
i = 0
break
An simple trick would be what i did, just have an entity saved for both branch and semester , use sys.original parameters and an common phrase for provoking each intent saves up the hard work.

updating existing data on google spreadsheet using a form?

I want to build kind of an automatic system to update some race results for a championship. I have an automated spreadsheet were all the results are shown but it takes me a lot to update all of them so I was wondering if it would be possible to make a form in order to update them more easily.
In the form I will enter the driver name and the number o points he won on a race. The championship has 4 races each month so yea, my question is if you guys know a way to update an existing data (stored in a spreadsheet) using a form. Lets say that in the first race, the driver 'X' won 10 points. I will insert this data in a form and then call it from the spreadsheet to show it up, that's right. The problem comes when I want to update the second race results and so on. If the driver 'X' gets on the second race 12 points, is there a way to update the previous 10 points of that driver and put 22 points instead? Or can I add the second race result to the first one automatically? I mean, if I insert on the form the second race results can it look for the driver 'X' entry and add this points to the ones that it previously had. Dunno if it's possible or not.
Maybe I can do it in another way. Any help will be much appreciated!
Thanks.
Maybe I missed something in your question but I don't really understand Harold's answer...
Here is a code that does strictly what you asked for, it counts the total cumulative value of 4 numbers entered in a form and shows it on a Spreadsheet.
I called the 4 questions "race number 1", "race number 2" ... and the result comes on row 2 so you can setup headers.
I striped out any non numeric character so you can type responses more freely, only numbers will be retained.
form here and SS here (raw results in sheet1 and count in Sheet2)
script goes in spreadsheet and is triggered by an onFormSubmit trigger.
function onFormSubmit(e) {
var sh = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Sheet2');
var responses = []
responses[0] = Number(e.namedValues['race number 1'].toString().replace(/\D/g,''));
responses[1] = Number(e.namedValues['race number 2'].toString().replace(/\D/g,''));
responses[2] = Number(e.namedValues['race number 3'].toString().replace(/\D/g,''));
responses[3] = Number(e.namedValues['race number 4'].toString().replace(/\D/g,''));
var totals = sh.getRange(2,1,1,responses.length).getValues();
for(var n in responses){
totals[0][n]+=responses[n];
}
sh.getRange(2,1,1,responses.length).setValues(totals);
}
edit : I changed the code to allow you to change easily the number of responses... range will update automatically.
EDIT 2 : a version that accepts empty responses using an "if" condition on result:
function onFormSubmit(e) {
var sh = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Sheet2');
var responses = []
responses[0] = Number((e.namedValues['race number 1']==null ? 0 :e.namedValues['race number 1']).toString().replace(/\D/g,''));
responses[1] = Number((e.namedValues['race number 2']==null ? 0 :e.namedValues['race number 2']).toString().replace(/\D/g,''));
responses[2] = Number((e.namedValues['race number 3']==null ? 0 :e.namedValues['race number 3']).toString().replace(/\D/g,''));
responses[3] = Number((e.namedValues['race number 4']==null ? 0 :e.namedValues['race number 4']).toString().replace(/\D/g,''));
var totals = sh.getRange(2,1,1,responses.length).getValues();
for(var n in responses){
totals[0][n]+=responses[n];
}
sh.getRange(2,1,1,responses.length).setValues(totals);
}
I believe you can found everything you want here.
It's a form url, when you answer this form you'll have the url of the spreadsheet where the data are stored. One of the information stored is the url to modify your response, if you follow the link it will open the form again and update the spreadsheet in consequence. the code to do this trick is in the second sheet of the spreadsheet.
It's a google apps script code that need to be associated within the form and triggered with an onFormSubmit trigger.
It may be too late now. I believe we need a few things (I have not tried it)
A unique key to map each submitted response, such as User's ID or email.
Two Google Forms:
a. To request the unique key
b. To retrieve relevant data with that unique key
Create a pre-filled URL (See http://www.cagrimmett.com/til/2016/07/07/autofill-google-forms.html)
Open the URL from your form (See Google Apps Script to open a URL)

Get google search number of result in scala

I am looking for a way to catch total number of results to a search on google (the "About **** results" field). I searched on google API but it seems that you can't get total number. Does anyone have informations that way ? How can I implement it in Scala (or any other language...) ?
Thank you
You can use HTML agility pack. Simply navigate to
"https://www.google.com/search?q=" + WhatYouWantToSearch
and get content of it. After getting that urlcontent you can use code below
htmlDoc.LoadHtml(urlcontent);
HtmlAgilityPack.HtmlNode hnc = htmlDoc.DocumentNode.SelectSingleNode("//div[#id='resultStats']");
string[] text = hnc.InnerHtml.Split(' ');
return Convert.ToInt32(text[1].Replace(",", "").Replace(".", "").Trim());

Using changestamp in GoogleDocs (null changestamp)

I am trying to find the max changestamp so I can start using it. I tried the following:
URL url = "https://docs.google.com/feeds/default/private/changes?v=3"
ChangelogFeed foo = service.getFeed(url, ChangelogFeed.class);
LargestChangestamp stamp = foo.getLargestChangestamp();
stamp is always null.
Is this the way to get the largest changestamp, or do I need to set it first in order to use it?
The largest changestamp is also available in the user metadata feed. See the "docs:largestChangestamp" element within the response protocol tab here,
I'm not sure the java api exposes the largestChangestamp property directly yet - last time I checked it was hidden in the xmlBlob property, and I had to do an xml parse to grab it out.
This seems to be a bug in the API. I got the changestamps by getting the ChangelogEntrys from the ChangelogFeed:
List<ChangelogEntry> entries = foo.getEntries();
for (ChangelogEntry entry: entries) {
String blob = entry.getXmlBlob().getBlob();
System.out.println("Blob: " + blob);
}
The changestamp for an entry is contained in its blob.