473,395 Members | 1,462 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Scraping data from a web form submit

Hi,
I want to build an app (C#, windows app, or web app, shouldn't make a
difference) that submits an address to the canada post website's address
lookup and then scrape the postal code out of the resulting page. Here is
their page. http://www.canadapost.ca/tools/pcl/bin/advanced-e.asp It uses a
form post.

I would like a basic rundown of how to submit my own info into their results
page (post), and then scrape out the info I need.
Thanks,
Brent
Nov 18 '05 #1
4 3233
1) use webclient class to call the website.
2) hit the page and view source to see what the input control names are
3) post the page with the values you want.
4) write code to parse the returning html for the values you want. a few reg
expressions ought to work.

-- bruce (sqlwork.com)

"Brent" <b@b.com> wrote in message
news:eq****************@tk2msftngp13.phx.gbl...
Hi,
I want to build an app (C#, windows app, or web app, shouldn't make a
difference) that submits an address to the canada post website's address
lookup and then scrape the postal code out of the resulting page. Here is
their page. http://www.canadapost.ca/tools/pcl/bin/advanced-e.asp It uses a form post.

I would like a basic rundown of how to submit my own info into their results page (post), and then scrape out the info I need.
Thanks,
Brent

Nov 18 '05 #2
in addition to Bruce's info, there is a tool (Fiddler) which is a
debugging proxy - it will capture all the HTTP traffic and allow you
to analyze it. This can be a great help when figuring out what you
need to POST.

http://www.fiddlertool.com/fiddler/

--
Scott
http://www.OdeToCode.com

On Fri, 24 Sep 2004 11:17:06 -0600, "Brent" <b@b.com> wrote:
Hi,
I want to build an app (C#, windows app, or web app, shouldn't make a
difference) that submits an address to the canada post website's address
lookup and then scrape the postal code out of the resulting page. Here is
their page. http://www.canadapost.ca/tools/pcl/bin/advanced-e.asp It uses a
form post.

I would like a basic rundown of how to submit my own info into their results
page (post), and then scrape out the info I need.
Thanks,
Brent


Nov 18 '05 #3
Thanks for the help, I got it now. Here is the full thing of code that I
used...
System.Collections.Specialized.NameValueCollection values = new System.

Collections.Specialized.NameValueCollection();

values.Add("street_number","113");

values.Add("street_name","MCINNES");

values.Add("prov","AB");

WebClient webclient = new WebClient();

webclient.Headers.Add("Content-Type","application/x-www-form-urlencoded");

byte[] responseArray = webclient.UploadValues(

"http://www.canadapost.ca/tools/pcl/bin/cp_search_response-e.asp","POST",

values);

string response = System.Text.Encoding.ASCII.GetString(responseArray );

this.message_textBox.Text=
response.Substring(response.IndexOf("AB",response.

IndexOf("PCLFormattedAddress"))+4,7);

"bruce barker" <no***********@safeco.com> wrote in message
news:ON**************@tk2msftngp13.phx.gbl...
1) use webclient class to call the website.
2) hit the page and view source to see what the input control names are
3) post the page with the values you want.
4) write code to parse the returning html for the values you want. a few
reg
expressions ought to work.

-- bruce (sqlwork.com)

"Brent" <b@b.com> wrote in message
news:eq****************@tk2msftngp13.phx.gbl...
Hi,
I want to build an app (C#, windows app, or web app, shouldn't make a
difference) that submits an address to the canada post website's address
lookup and then scrape the postal code out of the resulting page. Here is
their page. http://www.canadapost.ca/tools/pcl/bin/advanced-e.asp It uses

a
form post.

I would like a basic rundown of how to submit my own info into their

results
page (post), and then scrape out the info I need.
Thanks,
Brent


Nov 18 '05 #4
Aside from your current approach if I were you I would also ask
canadapost.ca if they intend to expose the data using web services
as every time their page changes you may have to rebuild your scraper.

--
<%= Clinton Gallagher, "Twice the Results -- Half the Cost"
Architectural & e-Business Consulting -- Software Development
NET cs*********@REMOVETHISTEXTmetromilwaukee.com
URL http://www.metromilwaukee.com/clintongallagher/

"Brent" <b@b.com> wrote in message
news:eq****************@tk2msftngp13.phx.gbl...
Hi,
I want to build an app (C#, windows app, or web app, shouldn't make a
difference) that submits an address to the canada post website's address
lookup and then scrape the postal code out of the resulting page. Here is
their page. http://www.canadapost.ca/tools/pcl/bin/advanced-e.asp It uses a form post.

I would like a basic rundown of how to submit my own info into their results page (post), and then scrape out the info I need.
Thanks,
Brent

Nov 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Matt | last post by:
The problem is I have 3 buttons that need to submit the form to different URL. My approach is to declare <input type="submit"> rather than <input type="button">. And put the following in the...
4
by: Brent | last post by:
Hi, I want to build an app (C#, windows app, or web app, shouldn't make a difference) that submits an address to the canada post website's address lookup and then scrape the postal code out of the...
4
by: Roland Hall | last post by:
Am I correct in assuming screen scraping is just the response text sent to the browser? If so, would that mean that this could not be screen scraped? function moi() { var tag = '<a href='; var...
1
by: Matt | last post by:
The problem is I have 3 buttons that need to submit the form to different URL. My approach is to declare <input type="submit"> rather than <input type="button">. And put the following in the...
4
by: Alex Sibilev | last post by:
Hello, I have a really weird problem I've been trying to solve it without any luck for the last couple of hours :( I'm writing a "conference board" application (quite similar to ASP.NET...
2
by: Victor | last post by:
I'm doing screen scraping by retrieving data from one site and entering into another site. I have a problem with logging into the site. User name and password field contain 'name' property, and...
2
by: Victor | last post by:
Hi, I have a problem with logging into web site via screen scraping. User name and password field contain 'name' property, and therefore I can easily do assignment to them:...
1
by: Nick | last post by:
What i wanted to do is make a webgame easyer, by getting the page, and in stead of having multiple click actions, make it all just 1 click and record stats for my profile. For Example: there...
0
by: Steve | last post by:
I am working on an application to screen scrape information from a web page. I have the base code working but the problem is I have to login before I can get the info I need. The page is hosted on...
0
by: Tarun | last post by:
I Have tried to fetch some XML data through screen scraping by the following code: System.Net.ServicePointManager.CertificatePolicy = New MyCertificatePolicy dim path as String="" Try Dim req...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.