How to automate the API call of a button in a website? - web-scraping

I am in a web app where I need to click a button every 2m and 30s. Out of curiosity, I wanted to see if I could automate this action.
So I started by trying to make the call the action of the button makes, in postman. Here's the URL of the button:
https://s43-gr.ikariam.gameforge.com/?action=PiracyScreen&function=capture&buildingLevel=1&view=pirateFortress&cityId=11055&position=17&activeTab=tabBootyQuest&backgroundView=city&currentCityId=11055&templateView=pirateFortress&actionRequest=0de6d9e98b3423da9d6c6db1a832ef54
I tried making a GET request and although I get a status of 200, nothing seems to happen.
I don’t really know how to do this, I just tried with my basic knowledge.

Related

PayPal Checkout popup randomly closes

We are having an issue in a Blazor WebAssembly app, which is using PayPal buttons for users to Add Funds to the system's wallet.
The issue is random, sometimes the popup closes immediately after opening, and does not allow users to even login into paypal to continue with the checkout process.
This is the js file: https://github.com/efonsecab/FairPlayTube/blob/main/src/FairPlayTubeSln/FairPlayTube.Client/wwwroot/js/paypal/paypal.js
This is the Blazor component which calls the js to render the buttons
https://github.com/efonsecab/FairPlayTube/tree/main/src/FairPlayTubeSln/FairPlayTube.Client/CustomComponents/Paypal
It happens constantly in dev, but not that much in prod.
This is the error shown in the console:
No ack for postMessage wn() in https://www.sandbox.paypal.com in 10000ms
The thing is that sometimes everything works successfully on the first try, but other show this.
Any ideas how to solve it?
If it closes immediately after opening, the createOrder function's invocation of actions.order.create is failing, likely due to an invalid request. Log everything, look at the console errors/output, and find out what you are doing wrong.
The object you are passing to actions.order.create can first be saved to a variable, logged with console.log(JSON.stringify(somevar,null,2)), and then return actions.order.create(somevar)
After several hours searching and trying numerous suggestions, I finally found the answer with this post: https://stackoverflow.com/a/66473740
For me, this solution works 100% of the time so far. I disabled Javascript debugging.

Application Insights removing telemetry after it has been logged

I've had Application Insights set up on my ASP.NET project for a couple months with no issues. I use Custom Events for logging certain events.
Recently, I tried to add a Custom Event after a user has authenticated in order to track the login behavior. My custom event DOES log to application insights debug session. I know this because I can see it in the telemetry when paused on a breakpoint just after the event.
However, when I continue running the application, my custom event no longer shows up the telemetry. It just disappears.
I cannot understand what the issue is. Does anyone familiar have any (application) insights? I couldn't help myself ;)
There are some things to check:
are you logging to one resource (iKey) and searching on another? (a lot of people send data to one resource in dev/debug and a different resource in release/prod environments. so make sure you're sending to the place you expect, and searching the place you expect.
is the data actually going out successfully? you may need to use fiddler or some other tool to watch your outbound http for calls to dc.services.visualstudio.com. It could somehow be the case that there's something wrong with the data you're sending, or maybe you're getting capped or throttled by the service. If that's the case, the outbound requests will have responses other than 200, and will generally tell you the reason it didn't accept any items that it rejected.
if the data is getting successfully sent and is going where you expect it to go, there might just be a delay in backend processing. you can always check aka.ms/aistatus to see if there are any current issues with the service.
I am confused, however, by what you mean when you say
However, when I continue running the application, my custom event no longer shows up the telemetry. It just disappears.
What do you mean "it just disappears" ? if you see it in the output window, then the SDK saw it, and it will get sent, precluding any of the above 3 items. Where is it "disappearing" from? unless you clear the output window, it's never gone from there. If you're talking about the VS search tools that show data sent by the AI SDK during debug, that tool currently has a cap of the most recent 250 items that have occurred during the debug session.

Is It Possible to stop a server request manually while the request is being processed by the server

I am using asp.net and Ajax functionalities to make requests to server via web services for a search functionality. On click of search button, I am making the screen inactive by displaying a loading image over it. The issue is some searches takes longer time, and the user is forced to wait till the results are fetched. Is there any way the search can be cancelled manually, like a button click while the search is being performed by the server.
Any help or alternates will be appreciated.
One thing you can try is to set timeout on your ajax call, take a look here:asp-net-page-webmethod-ajax-call-request-timed-out
Another thing is to use javascript setTimeOut to display the user a message after a few seconds saying "its taking too long. wait for results or Abort?" where the "Abort" is a link that refreshes the page.

IBM Worklight - How to use Worklight in a background process

I have an application that should run continuously even after the user presses the back button.
It has to send some data using POST method to my database in a remote server for every half an hour. This should happen even after the user has pressed the back button and the app should only stop when the mobile is switched off.
While I have set up the HTTP Adapter to send POST data and also an HTML file to call the adapter procedures on launch, I dont know how to make it background or which code to run to keep sending the POST data every half an hour.
It sounds like you are running on Android.
The expected behavior in Android is that pressing the Back button QUITS the application.
Moving to the background is performed by pressing the Home button.
So, I don't think you should do this when pressing the Back button... or maybe you should at least present the user the choice of either quitting or moving to the background (you can override the Back button by using WL.App.overrideBackButton).
That said, I am not familiar with a programmatic method to move to the background instead of quitting (maybe there is an existing Cordova plug-in or another way that does this).
The other way to accomplish this is by using an Android Background Service, however, Worklight does not have support in its Native API to do this.
As for what happens when the Worklight application is in the background, I have never tried it myself, so I cannot be certain at all, but try using WL.Client.setHeartBeatInterval to keep alive the connection to the Worklight Server and write some logic that sends the adapter requests. See if that would work for you...
I have found this:
How to create plugin in phonegap to run the application in background?
Maybe you'll be able to massage it into your Worklight project (in case the heartbeat approach above does not work).
More information on running in the background:
Android:
http://developer.android.com/training/basics/activity-lifecycle/index.html
http://developer.android.com/reference/android/app/Activity.html
iOS:
http://developer.apple.com/library/ios/#documentation/iphone/conceptual/iphoneosprogrammingguide/ManagingYourApplicationsFlow/ManagingYourApplicationsFlow.html
Override the Back button by using WL.App.overrideBackButton.,
remove the exit function in that method and leave it blank (if you want the background process not to exit when clicked)

URLLoader cancel load on any browser event

I have a flash element in a page that load a chart based on some complex queries that can take up to a minute to load. I call the query with this code :
var chartData:URLLoader = new URLLoader();
chartData.addEventListener(Event.COMPLETE, onLoaded);
chartData.addEventListener("httpStatus", onHttpStatus);
chartData.load(new URLRequest(chartURL));
I listen for the complete event or any server error event.
My problem is when a user want to go on another page while the flash is loading the URL : the browser is waiting for the url to be fully loaded before accepting the request of the user. As I say this chart can take up to a minute to load and it's kind of annoying for my users to wait if they want to change page.
Here is my question : Is there is an event to listen any event from the browser (click on another link, click on the "back" button of the browser...) ? If I'm wrong in my way to do this don't hesitate to tell me, I'm not really used to program in flash.
Thank you.
I think I understand what you're describing. Some things you might want to try out:
File Upload HTTP Server
If the files are very large, you might want to load them on another HTTP server, like Nginx. Check out the Nginx Upload Module (I'm sure Apache has the same thing). That basically allows you to upload files without making the user feel the impact at all.
The only problem with this is that it's pretty complex, and you won't know when the file is done uploading. But they do have examples of how to show Upload Progress Bars with Nginx using Javascript, so you could do something like that, and on completion (in javascript), send a message to flash that invokes something like your Event.COMPLETE handler.
Browser Events
There are browser events to intercept with Javascript to prevent your user from leaving the page until the download has completed (not recommended as it may annoy the user):
onexit
onclose
onblur (when they click somewhere else)
Check out this example: Javascript onclose: Warn the User.
Hope that helps,
Lance

Resources