I have to verify if an image file exist in website. However, when the certain URL cannot search for the image file, the site would quickly re-direct to prompt "imagenotfound.png" file making me difficult to get any macro code correctly prompt the image cannot be found, especially that imagenotfound.png file is already prompt up. Not sure if anyone can help? I am new to write macro.
thanks.
In which language?
You could use javascript for example:
function checkIfimageExists(imageurl){
var http = new XMLHttpRequest();
http.open('HEAD', imageurl, false);
http.send();
return http.status != 404;
}
Related
so I have some database on hosting, I created a PHP script to make this data accessible for my flutter app, so now I'm accessing this data like this.[![enter image description here][1]][1]
getMethod() async {
String theUrl = 'https://tchakrulo.space/getData.php';
var res = await http
.get(Uri.parse(theUrl), headers: {'Accept': 'application/json'});
var responseBody = await json.decode(res.body);
return responseBody;
}
everything works fine except when I'm adding a new entry or updating an existing one somehow my app still returns old data, even after restarting the app, so I want to get new data from json, every time the page loads
Perhaps your values are somehow cached, so if I were you, I would enter the command "flutter clean" into the console and remove the application from your device / emulator, and then reinstall it, if the problem persists, then you probably have a mistake in the code, double-check the correctness of the queries, as well as using the command print("Value: " + value.toString()); to check the values that you get through the console, try to track the path along which the values go and you will understand everything. All I can do is just give you an algorithm for solving your problem.
hello everyone I was tring to send files using my bot like http://api.telegram.org/botTOKEN/sendDocument?document=http://my_path&chat_id but it ain't support .txt .docx..... and other formats..... any help please
According to https://core.telegram.org/bots/api#sending-files
Sending by URL In sendDocument, sending by URL will currently only
work for gif, pdf and zip files.
You may try to use this approach
Post the file using multipart/form-data in the usual way that files
are uploaded via the browser. 10 MB max size for photos, 50 MB for
other files.
This answer might give you some ideas on how to do that.
UPDATE
It is also good idea to use someone's library to understand how it works there.
For example, I use longman/telegram-bot from this repo. There is encodeFile method in Request class.
Method is follows:
public static function encodeFile($file)
{
$fp = fopen($file, 'rb');
if ($fp === false) {
throw new TelegramException('Cannot open "' . $file . '" for reading');
}
return $fp;
}
Which means simple fopen method with 'rb' parameter is enough to convert file.
In our application, we have some pages where xsl transformation are happening using activex object Microsoft.XMLDOM. Its a legacy application, so there is not much scope for any changes.
Example:
<script>
var doc = new ActiveXObject("Microsoft.XMLDOM");
doc.async = false;
doc.load("/<<Some Path/myXSL.xsl");
document.write(myXML.transformNode(doc));
</script>
our HTTP server is sending correct cache-control, expiry attributes to the client end. The CSS, JS, Image files etc as we can see picked up from browser cache (status 304), but for XSL files, it is always hitting the server (status 200).
If we open the Temporary Internet Files, we can see although there is a future date is present against Expires column, but Last Checked is always getting updated against each request.
Any help here, would be much appreciated.
After searching a lot in google, we understood that ActiveX Microsoft.XMLDOM sends "pragma - nocache" in the request header (to skip the browser cache).
To solve this, we need to set ForcedResync property as false (telling the XML Dom object not to send that pragma).
Example:
<script>
var doc = new ActiveXObject("Microsoft.XMLDOM");
doc.async = false;
doc.setProperty("ForcedResync", false);
doc.load("/<<Some Path>>/myXSL.xsl");
document.write(myXML.transformNode(doc));
</script>
I'm using the Petrousos 'Google Maps' book, and trying to run the example in the CHAPTER17/HTML/Directions Service.html downloaded from the book's website at www.mhprofessional.com at item 0071823026.
I had to adjust the table dimensions to get it to display properly, but otherwise made no changes. I'm running it through Firefox.
I set the origin and destination and clicked "Show Directions", at which point nothing happened.
The event called the following function:
function showDirections() {
var start = document.getElementById("origin").value;
var end = document.getElementById("destination").value;
var request = {
origin: start,
destination: end,
travelMode: google.maps.TravelMode.DRIVING
};
directionsService.route(request, function(result, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(result);
printDirections(result);
}
});
}
I get as far as the directionsService.route call, but it is apparently not being executed, and status and result are not defined.
I have no idea how to debug this further, not having access to the API code..
Could the syntax of the call in the example be outdated?
I don't have an API key, but I understand it is not necessary, and I have run other examples without one.
Do you old examples still work? If not, then it's because you don't have an API key. Google will shut you down after you surpassed the quota. I believe the quota is at 50 requests per hours.
Google has the most recent documentation (and it's impressively well documented)
https://developers.google.com/maps/documentation/directions/intro#Audience
Also, can you look at what the object returns? If so, that will usually indicate the quote being surpassed. You can do this by setting a breakpoint at the link
if (status == google.maps.DirectionsStatus.OK) {
If you're using Chrome, you can get to the debugger by right-clicking on the page adn choosing 'Inspect Element', then go to sources, find your line of code and click the link number to set a breakpoint.
I have a spreadsheet on my Google Drive and I want to download a CSV from another website and put it into my spreadsheet. The problem is that I have to login to the website first, so I need to use some HTTP request to do that.
I have found this site and this. If either of these sites has the answer on it, then I clearly don't understand them enough to figure it out. Could someone help me figure this out? I feel that the second site is especially close to what I need, but I don't understand what it is doing.
To clarify again, I want to login with an HTTP request and then make a call to the same website with a different URL that is the call to get the CSV file.
I have done a lot of this in the past month so I should be able to help you, we are trying to emulate the browsers behaviour here so first you need to use chrome's developer tools(or something similar) and note down the exact things the browser does like the form values posted, the url that is called and so on. The following example shows the general techinique to be used:
The first step is to login to the website and get the session cookie:
var payload =
{
"user_session[email]" : "username",
"user_session[password]" : "password",
};// The actual values of the post variables (like user_session[email]) depends on the site so u need to get it either from the html of the login page or using the developer tools I mentioned.
var options =
{
"method" : "post",
"payload" : payload,
"followRedirects" : false
};
var login = UrlFetchApp.fetch("https://www.website.com/login" , options);
var sessionDetails = login.getAllHeaders()['Set-Cookie'];
We have logged into the website (In order to confirm just log the sessionDetails and match it with the cookies set by chrome). The next step is purely dependent on the website so I will give u a general example
var downloadPayload =
{
"__EVENTTARGET" : 'ctl00$ActionsPlaceHolder$exportDownloadLink1',
};// This is just an example it may or may not be needed, if needed u need to trace the values from the developer tools.
var downloadCsv = UrlFetchApp.fetch("https://www.website.com/",
{"headers" : {"Cookie" : sessionDetails},
"method" : "post",
"payload" : downloadPayload,
});
Logger.log(downloadCsv.getContentText())
The file should now be logged, you can then parse the csv using hte GAS inbuilt function and dump the data in the spreadsheet.
A few points to note:
I have assumed that all form post values are static and can be
hardcoded, in case this is not true then let me know I will give you
a function that can extract values from the html.
Some websites require the browser to send a token value(the value will be present in the html) along with the credentials. In this case you need to extract the values and then post it.