Android Question implant data in a webpage

pati

Member
hello everyone
I'm new in b4a and I've just started using trial version and I came up with a question.
I've got a webpage with 2 edit texts,one of them recieves a number and the other one recieves Captcha code, and a submit button.
In my application I want to have 2 edit texts which their texts will be put inside webpage's edit texts, an Imageview which will show the Captcha picture and a button which will send the data to webpage when clicked.
Can anyone help me trough this problem?? I'm really going crazy about this.
I know how to send data to a webpage,thanks to b4x community, but I don't know what to do about Captcha...:(:(

please help me...:confused::confused:
 

Mark Read

Well-Known Member
Licensed User
Longtime User
I have done something similar using WebVewExtras. You can then inject javascript into the webpage to get variables and press buttons. I looked through the source code for the webpage to find the URL which was called when the submit button was pressed, if that makes any sense to you. You can search the forum for WebVewExtras or post the URL for the webpage and someone will try to help you.

However, I think that this will not help you in the trial version, as the libraries will not be available.
 
Upvote 0

pati

Member
The problem is that the webpage is not created by me and it's not mine.
It's a post tracking website.It recieves the consignment's number and a captcha code,then It shows you where your item is.
I want to do this programmatically.
Please help
 
Upvote 0

Mark Read

Well-Known Member
Licensed User
Longtime User
The problem is that the webpage is not created by me and it's not mine.

You don't understand. That is not a problem. You create a webview in your app and add WebViewExtras to it. Then you load the URL and can use javascript in your webview. Another way to think of it is like using a remote control to operate the webpage. You do not do anything to the original, you only use what you load in your app. Clear?

Please help
You do not need to ask for help. That is what the forum and its members are here for!

Here is a partial example of what I mean (do not try to run it)

B4X:
Sub Globals
    Dim WebView1 As WebView     'Create a webview
    Dim WebViewExtras1 As WebViewExtras    'Get the extras
    
End Sub

Sub Activity_Create(FirstTime As Boolean)
    HttpUtils.CallbackActivity = "Main"
    HttpUtils.CallbackJobDoneSub = "JobDone"
       
    'This is the webview with the router which we will hide
    WebView1.Initialize("WebView1")
    Activity.AddView(WebView1,0,0,Activity.Width,Activity.Height)
    WebViewExtras1.addJavascriptInterface(WebView1, "B4A")        'Inject javascript into YOUR webview
    WebViewExtras1.addWebChromeClient(WebView1,"")

     'The URL I have modified to suit my needs
    WebView1.LoadUrl("http://routino.grade.de/?transport=foot;lon1=12.97565;lat1=53.28092;lon2=13.23413;lat2=53.16854;lat=53.17522;lon=13.27600;zoom=13")
    
   
End Sub

Sub WebView1_PageFinished (Url As String)
    Log("URL has finished loading ...")
    WebViewExtras1.executeJavascript(WebView1,"findRoute('shortest')")     'Press the button called findroute
    
End Sub
 
Upvote 0

pati

Member
I think you haven't got my problem.for communicating with a webpage we need to load that page in a webview,and when it's loaded in a webview,a specific captcha is made.There is no way to get that captcha.The only way is to download that Captcha picture by httputils.But when you download it,the picture is different from what is loaded in webview.So when the user enters the captcha code in your application and you send it to webpage (loaded by webview),it is not true.
I wish you get what I mean
 
Upvote 0

An Schi

Well-Known Member
Licensed User
I'm sure you cannot solve a captcha programmaticaly.
Because that is what captchas were invented for :D

But the rest is right - you can easily make a b4a app which fills username, password and other formfields automaticaly.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
The problem is that the webpage is not created by me and it's not mine.
It's a post tracking website.It recieves the consignment's number and a captcha code,then It shows you where your item is.
I want to do this programmatically.
Then ask the creator of the website to use an API for this. Use this API then to access the results.

Usually it is not legal what you are trying to do.
But using webviewextras and injecting javascript is most probably the way you need to go for this if there is no API.
 
Upvote 0

pati

Member
But using webviewextras and injecting javascript is most probably the way you need to go for this if there is no API.

Could you please tell me how.I couldn't find anything working in this froum.the page isn't .php,it's .aspx
 
Upvote 0
Top