I'm successfully opening pages with
Dim o As Object
o = CreateObject("InternetExplorer.Application")
o.navigate2("http://www.google.com")
Is it possible to navigate webpage without loading images ?
1) This is VBS or VB6, not VB.Net.
2) You are essentially starting IE, it's up to the user to go to their options and
let IE load up images or not.
What are you trying to do?
Related
Hi I am trying to write a scraper to get data from this website (www.coned.com/tcisng) and dump data into my Ms Access Backend. When I navigate to it and enter in my credentials (username and password), it does not activate the "Log In" button which I want to click next as it is the next step on my scraper. Also this "Log In" button has no name or ID. How to activate and make it click using VBA in Ms Access 2016.
Updated Code Snippet -
Dim ie As Object
Set ie = CreateObject("internetexplorer.application")
ie.Visible = True
ie.Navigate "www.coned.com/tcisng"
While ie.Busy
DoEvents
Wend
Do
DoEvents
Loop Until ie.ReadyState = READYSTATE_COMPLETE
ie.Document.all("LoginEmail").Value = "myemail"
ie.Document.all("LoginPassword").Value = "myPassword"
Do
DoEvents
Loop Until ie.ReadyState = READYSTATE_COMPLETE
While ie.Busy
DoEvents
Wend
'ie.Document.all(48).Click
'ie.Document.querySelector("[type=submit]").Click
ie.Document.querySelector("button[title*='Log in']").Click
In the last 3 line I am trying to select the "Log In" button but it is disabled, also it has no name or ID, can you also help what exact code to replace in order to activate the button and click it later.
Instead of trying to "click" the button, try submitting the form. The Javascript for that ConEdison page would be:
document.getElementById("form-login-email").form.submit()
In the "old days", with just a plain form, this would work fine.
But on that website there is a lot more going on. That email input element has nine events attached to it. By just filling in the value, you aren't triggering any of those events.
With forms built with ReactJS, for example, the user's interaction with the Input element is monitored, and the value is extracted and stored in a non-displaying object in the DOM tree. When the Submit button is clicked, the form's visible Input elements may not be used at all. In order to feed inputs into such forms, you need to understand ReactJS data structures, and manipulate them directly.
I recently built a scraper based on Chromedriver, which allows a Chrome browser window to be controlled from an external program, such as Access VBA. Once started, Chromedriver runs as a mini-webserver on localhost, and commands sent to it from Access VBA (through a ServerXMLHTTP60 object) cause it to launch Chrome, visit a URL, send keystrokes to input elements etc. Within the browser, the keystrokes fire all the events that human keystrokes would do. The target website was ReactJS-based, but I was able to ignore all of the internal complexity of ReactJS.
Since the website runs in a regular Chrome browser, I was able to use F12 Developer Tools in the development process.
The technology is Webdriver, and was developed for building website testing tools. There are Firefox and MS Edge Chromium versions as well.
I am trying to automate a process of downloading file from a website. At the moment I am able to open a link that runs a javascript which produces an output file, here's my code:
Sub WebDataExtraction()
Dim URL As String
Dim IeApp As Object
URL = "http://si3.bcentral.cl/Siete/secure/cuadros/DescargarExcel.aspx?DropDownListFrequency=&DrDwnCalculo=NONE&codCuadro=UF_IVP_DIARIO"
Set IeApp = CreateObject("InternetExplorer.Application")
IeApp.Navigate URL
End Sub
When I run the sub the IE View Downloads window pops out. To download the file I am trying to follow this approach, however while I am using the attached code I am unable to find a child window.
Can somebody advise me how to proceed from here? Or maybe any suggestion how to approach this problem differently?
Is it possible to download a file using MVC4 to iPad instead of showing the file in the browser when clicked?
On my webpage, I am showing a table of files (can be any type) and when clicked on the file names, the file should be downloaded to the iPad.
I am using:
Public Sub GetItem(ByVal fileId As Guid)
Dim sDirectory As String = Commands.Folder.MapFullPath(fileId)
sDirectory = ApplyClusterServerHACK(sDirectory)
Me.HttpContext.Response.Clear()
Me.HttpContext.Response.ContentType = "application/octet-stream"
Me.HttpContext.Response.AddHeader("Content-Disposition", "attachment;filename=" & System.IO.Path.GetFileName(sDirectory))
Me.HttpContext.Response.TransmitFile(sDirectory)
Me.HttpContext.Response.End()
End Sub
to get the file and it's working perfectly in desktop browsers. It is prompting if I want to open it or save it, and choosing save opens up the location dialog box where I can select where to save it.
Can this be done in an iPad? If not, do you have any alternate idea how to make it work? Using the Back button on the browser is off-limits since I am running the application full-screen using a "stub" without any menu bars.
I have a piece of code that opens a web page in my default browser (IE10).
Dim url As String
url = "http://www.google.com"
Process.Start(url)
How do I then pass a value to the text box on that page. I am using google as an example. I am using VS2013, VB and asp.net
Thanks
This video should give you all of the information that you need. It is a tutorial on creating an automatic yahoo login from vb, but it will show you how to pass values to a textbox on a webpage, as well as working with other webpage controls.
NOTE: You will need to navigate to the page and view source to get the id of the controls
I need to copy an image from a webbrowser control to my clipboard, because the image changes on every reload, and I tried to get the "src"-attribute and changing my picturebox.imagelocation to that, but the image on the picturebox differed from the picture on the webbrowser control.
I'm trying to automate a web service, and it requires a captcha to be filled out, and it changes every time the page is loaded, that's why I need to get the one that is currently displayed.
Assuming you are using Windows Forms (need to change the way to get document if you use WPF) and the user did not block clipboard access in IE zone settings
Dim doc As IHTMLDocument2 = DirectCast(webBrowser1.Document.DomDocument, IHTMLDocument2)
Dim body As IHTMLElement2 = DirectCast(doc.body, IHTMLElement2)
Dim imgRange As IHTMLControlRange = DirectCast(body.createControlRange(), IHTMLControlRange)
Dim image As IHTMLControlElement = DirectCast(DirectCast(doc, IHTMLDocument3).getElementById(sImgID), IHTMLControlElement)
imgRange.add(image)
imgRange.execCommand("Copy", False, Nothing)
Pseudo code:
For each element by tag 'img'. Get the 'src' attribute. Fire up an instance of HttpWebRequest or use WebClient.DownloadFile for the source.
You will need to do some trickery determining where the source is in relation to the url. For instance the src could be '/img/pony.jpg', in which case you'll need to get the url's root from the WebBrowser control to make it 'http://mylittle.com/img/pony.jpg'.