C++ API to auto fill Web Forms and Submit Pages?

1,774 views
Skip to first unread message

Dalton Fury

unread,
May 2, 2015, 3:29:54 AM5/2/15
to chromi...@chromium.org
Hey,
I am working in an factory which employees 200+ contract workers. They don't have internet or computer access. Out government has issued a number, called UAN which will get them a lot of benefits.

All that stands between them an the number is an online verification process. I thought of helping them out by collecting all the information required and typing it into a file. Then is there a way to automate this process? I know c++, so any api's available for this purpose? Any other methods?

This is the site i am talking about?

pratik dand

unread,
May 2, 2015, 3:44:13 AM5/2/15
to dalton...@gmail.com, chromium-dev
Hie,

I hope you already know the structure of the webpage/form you are trying to fill. In that case, using scrapy (python based crawler) along with this interface, you can fill the forms. The code at the link fills and submits login forms, you should be able to extend it for your usecase. I understand you mentioned C++ as your preferred language but learning python and getting started with scrapy is as easy as writing a Hello World Program.

Hope this helps!

--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev

To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev...@chromium.org.



--
Pratik

PhistucK

unread,
May 2, 2015, 6:14:28 AM5/2/15
to pratik...@gmail.com, dalton...@gmail.com, chromium-dev
If you want to use a browser for this (and you probably should, in case there is any JavaScript that modifies stuff in the form prior to its submission), you can create a Chrome extension that does that.
Alternatively, you can search the Chrome web store for an existing extension. Perhaps there is one.


PhistucK

Christopher Smith

unread,
May 3, 2015, 4:40:22 AM5/3/15
to chromi...@chromium.org
You can use the Selenium web driver which has a Java and C# API. With not much code you can automate opening a web page, filling out a form, clicking buttons/elements and then picking elements from a page and parsing their text content.

The C# and Python API are very similar.


The few basic API calls you would need are (example in Java):

// Instantiate driver (opens a firefox browser window)
RemoteWebDriver driver = new FirefoxDriver();

// Load the desired page
driver
.get("http://website.com/form");

// Pick out an input element and type a value
WebElement nameInputElement = driver.findElement(By.id("name-input-css-id"));
nameInputElement.sendKeys("Your name");

// Get the form element and submit the form
WebElement formElement = driver.findElement(By.id("form-element-css-id"));
formElement
.submit();

// submit() will block until page has finished loading

// Get ID number
WebElement idNumberElement = driver.findElements(By.cssSelector("#confirmation > span")).get(0);
String idNumber = idNumberElement.getText().trim();

Reply all
Reply to author
Forward
0 new messages