-2

Possible Duplicate:
How to convert std::string to LPCSTR?

I'm interested in making a function which will go through a range of pages on a website and download the information from each one. For example - mywebsite.com/?page=1, mywebsite.com/?page=2, ?page=3, etc. I thought it would be easy to do this automatically, but apparently not. To download the HTML source I've been using a function called URLOpenBlockingStream(). This function takes the URL of the site as a parameter, as data dype LPCSTR (I assume "Long Pointer to Constant String"). This seems to stop it from going to any website except an exact one which I hard-code in.

All reasonable attempts to circumvent this problem have resulted in either a compile or runtime error. Is there a way around it, or perhaps another function I should be using?

Thanks in advance!

I have just worked this issue out after a lot of trouble and googling. Sorry, it won't let me answer my own question because I'm new, but for anyone looking, here's how it works:

First, get all your URL into one string. Look up stringstreams if you need to know how to convert an int or whatever. Then, use string::c_str(), which returns a constant string, which can then be converted into an LPCSTR.

Community
  • 1
  • 1
  • Sorry for managing to mess up the title, post and tags all on the same post. Pretty impressive though. – user1620639 Aug 23 '12 at 22:38
  • You can answer your own question, [you just have to wait 8 hours before it will let you](http://meta.stackexchange.com/questions/86185/minimum-reputation-for-answering-your-own-question-should-be-higher-than-what-is). – Esoteric Screen Name Aug 24 '12 at 14:45

1 Answers1

0

It would help if you attached your code. Pretty difficult to tell what's wrong without it.

Also, you may want to install a network sniffer like wireshark to see if any communication is being sent to the server at all, and if the response code is ok etc.

Last, I would look at this example from MSDN: http://msdn.microsoft.com/en-us/library/aa741006(v=vs.85).aspx#Using_the_URL_Functi

Nimo
  • 7,984
  • 5
  • 39
  • 41
  • Thanks for the reply. I've put a few code examples in which should help explain the issue - I understand how to use URLOpenBlockingStream, but the issue comes when I want the website to be decided by some external input. – user1620639 Aug 23 '12 at 23:28