进行网络请求时如何获取验证码?
我让我的用户注册一个电子邮件帐户,用户只需填写我的程序中的所有信息,我的程序将填充这些字段。好吧,实际上并不是,它使用正确的 postdata 向正确的表单/post url 发出 POST 请求。
然而,该网站需要验证码,我只是想向我的用户显示验证码,他输入值,然后它与帖子数据一起发送。
注册页面在这里: http://register.rediff.com/register/register .php?FormName=user_details
我可以从 html 中获取所有图像 url,但是当我复制验证码图像的 url 并转到它时,它是一个与我复制 url 的图像不同的图像:
http://register.rediff.com/register/tb135/tb_getimage .php?uid=1312830635&start=JTNG
如何使用 HttpWebRequest 执行此操作? 我可以先获取 html:
string html = new WebClient().DownloadString("http://register.rediff.com/register/register.php?FormName=user_details ");
然后获取图像网址,但我不知道如何向用户显示相同的验证码?
顺便说一句,它不是针对机器人的......它不是自动化的东西......只是我不希望用户显示网络界面......
I'm letting my users register an email account, the users just fills in all information in my program and my program will fill the fields. Well not really it makes a POST request with the correct postdata to the correct form/post url.
However the website requires a captcha, I just simply want to show the captcha to my user, he enters the value and then it gets send along with the postdata.
The register page is here: http://register.rediff.com/register/register.php?FormName=user_details
I can just get all image urls from the html but when I copy the url of the captcha image and go to it, it's a different image then the image i copied the url from:
http://register.rediff.com/register/tb135/tb_getimage.php?uid=1312830635&start=JTNG
How do I do this using HttpWebRequest ?
I can just grab the html first:
string html = new WebClient().DownloadString("http://register.rediff.com/register/register.php?FormName=user_details ");
Then get the image url but I don't know how to show the same captcha to the user?
Btw it's not for a bot... it's not something automated.. it's just I don't want the user to show the webinterface...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不是真正的答案,而是一些建议:
如果您正在编写一个应用程序客户端来与网站一起工作,更好的方法是编写一个 WCF/WebService 供应用程序直接交互 - 这可以直接引用您的 BL 层。
如果您希望整个应用程序在屏幕抓取上运行,那么前面还有大量工作要做,并且您的应用程序将依赖于不更改的网站。
Not really answer, some advice instead:
If you're writing an app client to work with the website, a better approach would be to write a WCF/WebService for the App to interact with directly - this can just refer directly to your BL layer.
If you want the whole app to work on screen scraping then that's a lot of work ahead, and your app will be dependent on the site not being changed.