C # simulation Baidu Login and comment on the designated website replies (V)

Source: Internet
Author: User

The previous four have said all the simulation Baidu login, the next is to the designated site to comment, of course, you may also be to obtain other information, in fact, these routines are original aim, understand that after the feeling like this request-response to obtain information function is very simple (think of the detour, it is too sad)

Today's detailed review process is not much to say, here is the point I write this function when the problem encountered, it is these problems caused by the dilemma. (mainly theory, there is no understanding of children's shoes welcome Comment Exchange)

The first question: if the use of Baidu login site, then before we get to Bduss, here will be converted. Because I visited the page, when visiting the homepage will go through Bduss to continue the request, to get a new bduss of the site, which means that in front of so much effort we actually only got a key. To open the door to information, we need to open the other doors.

What is to be said here is-- logical Analysis , this is too important, after entering the new site we need to re-analyze, find the main Request Response page, sometimes the page will be multiple jumps, the information will change. If we really want to do a full simulation, we have to do a lot of work, so here we just have to find the request response page that has the information we need.

For example, I want to get the site's own Budss, then contact before and after the content, to see which page to use the new BUDSS, and then back again, slowly exclude, until find the response to which Bduss page. This process is a test of patience and carefulness, and nothing to do with anything else.

The second question: Cookie! This is the absolute condition that determines whether the function can be implemented smoothly, without these two, the code is wrong!

So, when you go to a new website, be sure to analyze what new cookies are in place and collect them all. I just write the comment function, get the website verification code, although can get, but always error, this is not get sessionid and cookie consequences. To request a Web page verification code, must have these two things, if you see your own wrong, then look at the cookie collector there are no such values! Because the site to identify you are not the same person to take the verification code and then submit, see is SessionID, so must have this value.

Here is the specific implementation code: Here you do not have to know too deep, just need to know that the following code is to constantly request a different page, and then get the response, until the Request verification code page needs to obtain the cookie and parameters are completely, and then initiate the request. The value of the note is that each page has a certain logic between the middle skipped some unnecessary pages, so everyone in the analysis of the time to be serious.

// <summary>
/// Package Get Comment Page verification code
// </summary>
public void Getcommentcode (string BookID, String booklink, Httphelper Helper, PictureBox PictureBox)
{
stringCorrssmain_do_getbudss = string. Format ("Http://passport.zongheng.com/bdpass/crossdomain.do?bdu={0}&t={1}", " Mw5rmkpwvjjwslntzdfirtlytfvsmllybhvusgd3vtfwbfjrmupxvxrcyurwdextmvlhmmt6veg1tgfhulhrvkzcuvvgqkpduufbqufbqufbqufbrufbqujgm Jvjc3u2alq2czdvelayn3fouhfbqufbqufbqufbqufbqufbqufbqufbqufbqufbqufbqufbqufbqufbqufbqufbqufbqufbqufbqufbqufbqufbqufbqufqlw Q3mvh+bmu5vmfr ", Utility.gettimestamp ());
stringUrl_maindo = string. Format ("Http://passport.zongheng.com/pclogin/main.do?_t={0}&source=0&bduss={1}&location={2}", Utility.gettimestamp (), "kjbrdxvy560zxpcyv0f0ag8jyzkmggdurci7ibdjsrinuxdhx19o~m98ajz7s0jkqcie4rdroe~ l619b2jmrepdr6tvwxdwfkv4g67lnk89egiteu8tmrvipqterth7ujge09blnvolstep9qtkae~mrwqd9wn7jreld* ygwzoexebt3r8ksubjvef3kez4vkdojdcc1yuig*xdaexz6hhpnzndvfngqud3acgcenzypwebyqxifbiw* irhls9bceds2fp1ox8ixypc0xpvvopahme6hsom1b5jtjexoont0c17oelswmhm3lp0~wlhahy~sq0dts9km7t84yjkzpa== ", Utility.urldecode ("http%3a%2f%2fwww.zongheng.com%2f"));
stringUrl_getsession = string. Format ("http://book.zongheng.com/ajax/book.comment.getThreadL1st2.do");//This page is in response to SessionID
stringPostdata_session = string. Format ("bookid={0}&pagebar=0&pagenum=1&pagesize=30", bookId);//Get Sessinid
Helper. Getpageresponse_get (Corrssmain_do_getbudss, Utility.urldecode ("http://passport.zongheng.com/?location=http%3A% 2f%2fwww.zongheng.com%2f ")," image/png,image/*;q=0.8,*/*;q=0.5 ");
Helper. Getpageresponse_get (Url_maindo, Utility.urldecode (Booklink), "text/html,application/xhtml+xml,application/xml;q= 0.9,*/*;q=0.8 ");
Helper. Getpageresponse_post (Url_getsession, postdata_session, Booklink);

After all the cookies have been collected, the request verification code is started.
Bitmap bp = helper. GetCode (String. Format ("http://passport.zongheng.com/imgcapt?r={0}", Utility.gettimestamp ()), booklink);
Picturebox.image = BP;
}
#endregion

OK, all the functions of this project are finished here, what's the problem? Welcome to comment Exchange

C # simulation Baidu Login and comment on the designated website replies (V)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.