Name: Anonymous 2007-04-13 10:23 ID:+IKYbSzl
/prog/, I have a problem. I am trying to scrape store locations of walgreens for a client. Don't ask, I'm just doing shit to get paid. Problem is, this form sucks. I get the post data, populate it with what is needed, post it, and get the search form as a result instead of store locations.
I know the post data is correct. I used a program I found on a programming site that has a webbrowser control, http request data, http post data and http response data. I used the webbrowser control to navigate to the site, peform a store location search, and get results. The data url and postdata found in the below code was taken directly from this program after the search.
It's my first time, be gentle.
I know the post data is correct. I used a program I found on a programming site that has a webbrowser control, http request data, http post data and http response data. I used the webbrowser control to navigate to the site, peform a store location search, and get results. The data url and postdata found in the below code was taken directly from this program after the search.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Net;
using System.IO;
namespace FuckThisShit
{
class YouBetterWorkFucker
{
static void Main(string[] args)
{
string url = "http://www.walgreens.com/storelocator/result.jsp?_DARGS=/storelocator/find_fg.jsp";;
string postData ="_dyncharset=ASCII&address=&_D%3Aaddress=+&city=&_D%3Acity=+&_D%3A%2Fstorelocator%2FWalgreensLocator.state=+&%2Fstorelocator%2FWalgreensLocator.state=&zip=48186&_D%3Azip=+&_D%3A%2Fstorelocator%2FWalgreensLocator.searchList=+&_D%3Aradius=+&radius=5&_D%3A%2Fstorelocator%2FWalgreensLocator.searchList=+&_D%3A%2Fstorelocator%2FWalgreensLocator.searchList=+&_D%3A%2Fstorelocator%2FWalgreensLocator.fluInd=+&_D%3A%2Fstorelocator%2FWalgreensLocator.getMap=+&%2Fstorelocator%2FWalgreensLocator.getMap=10&_D%3A%2Fstorelocator%2FWalgreensLocator.getMap=+&_DARGS=%2Fstorelocator%2Ffind_fg.jsp&%2Fstorelocator%2FWalgreensLocator.getMap.x=74&%2Fstorelocator%2FWalgreensLocator.getMap.y=13";
System.Console.WriteLine("Starting post...");
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
req.UserAgent = "Mozilla/4.0";
req.ProtocolVersion = HttpVersion.Version10;
req.ContentType = "application/x-www-form-urlencoded";
req.Method = "POST";
req.KeepAlive = false;
byte[] bytes = System.Text.Encoding.ASCII.GetBytes( postData);
req.ContentLength = bytes.Length;
System.Console.WriteLine("Posting data...");
Stream os = req.GetRequestStream();
os.Write(bytes, 0, bytes.Length);
os.Close();
WebResponse resp = req.GetResponse();
StreamReader sr = new StreamReader(resp.GetResponseStream());
System.Console.WriteLine("Reading results data...");
StreamWriter sw = new StreamWriter("results.txt");
sw.Write(sr.ReadToEnd().Trim());
sw.Close();
System.Console.WriteLine("Done.");
}
}
}It's my first time, be gentle.