为什么.NET后从卷曲有什么不同?破碎?卷曲、有什么不同、NET

2023-09-03 15:13:28 作者:薄荷丫头

注:我固定用户代理的问题,我还添加了一个额外的字节相匹配的内容长度。没有运气但是。

我不明白这一点。我跑这code以下,结果JSON字符串是链接已过期(意为无效)。

不过卷曲code做同样的事情和工作。我要么得到的URL期望的字符串,或者说,我需要等待(几秒钟到1分钟)。

为什么呢?最新两者之间的区别是什么?它看起来非常F%^&放大器; *编起来,这是不同的行为(它已经引起了我的问题小时)

注:由站点所需的唯一cookie是SID(测试)。它拥有你的会话ID。第一次发帖激活它与第二个命令检查与返回的JSON字符串的状态。随意设置的CookieContainer只使用SID如果你喜欢。

警告:你可能想SID更改为不同的值,这样其他人的arent激活它。您可能需要运行的第2个URL,以确保会议ID不使用,说过期/无效,然后再开始。

附加说明:与卷曲或在您的浏览器,如果你做的POST命令,你可以坚持的SID在.NET中的cookie容器和第二个命令将工作。但这样做的第一个命令(POST数据)将无法正常工作。这篇文章的功能我已经用于许多其他网站需要后,至今它已经奏效。显然,检查方法是一个大问题,我看到这的确是POST做的第一个命令的时候。

 静态无效的主要(字串[] args)
    {
        VAR饼干=新的CookieContainer();
        的PostData(http://uploading.com/files/get/37e36ed8/,行动= second_page和放大器; FILE_ID = 9134949&放大器code = 37e36ed8,饼干);
        Thread.sleep代码(4000);
        VAR水库= PostData("http://uploading.com/files/get/?JsHtt$p$pquest=12719362769080-xml&action=get_link&file_id=9134949&$c$c=37e36ed8&pass=undefined",
            空/ *这使得GET * /,饼干);

        Console.WriteLine(RES);
        / *
        卷曲-bSID = 37468830-ADUMMY_User_Aggent-d行动= second_page和放大器; FILE_ID = 9134949&放大器code = 37e36ed8http://uploading.com/files/get/37e36ed8/
        卷曲-bSID = 37468830-ADUMMY_User_Aggent "http://uploading.com/files/get/?JsHtt$p$pquest=12719362769080-xml&action=get_link&file_id=9134949&$c$c=37e36ed8&pass=undefined"
        * /
    }
 

我受够了的HttpWebRequest / .NET htto客户。我这样做是使用curl(学习如何设置它在.NET和刷新自己后)。我做到了简单,快速,它的工作。没有愚蠢的问题。

  Curl.GlobalInit((INT)CURLinitFlag.CURL_GLOBAL_ALL);
        VAR卷曲=新易();
        curl.SetOpt(CURLoption.CURLOPT_USERAGENTDUMMY_User_Aggent);
        curl.SetOpt(CURLoption.CURLOPT_COOKIE,SID = 4385743);


        curl.SetOpt(CURLoption.CURLOPT_POSTFIELDS,行动= second_page和放大器; FILE_ID = 9134949&放大器code = 37e36ed8);
        curl.SetOpt(CURLoption.CURLOPT_URLhttp://uploading.com/files/get/37e36ed8/);
        curl.Perform();


        curl.SetOpt(CURLoption.CURLOPT_POST,0);
        Easy.WriteFunction WF =新Easy.WriteFunction(OnWriteData);
        curl.SetOpt(CURLoption.CURLOPT_WRITEFUNCTION,WF);
        curl.SetOpt(CURLoption.CURLOPT_URL, "http://uploading.com/files/get/?JsHtt$p$pquest=12719362769080-xml&action=get_link&file_id=9134949&$c$c=37e36ed8&pass=undefined");
        curl.Perform();

        curl.Cleanup();
        Curl.GlobalCleanup();
 

解决方案

显然,你想下载的uploading.com一些与程序,这是他们不希望你来。 既然你不发送带有袅袅的UserAgent,他们没有办法知道你是自动化的,但.NET可能会发送被列入黑名单的用户代理的。

昨晚欧美股市继续下跌,下周一A股该怎么办

NOTE: I fixed the user agent problem and i also added in an extra byte to match the content length. No luck however.

I dont understand this. I ran this code below and the result json string was the link is expired (meaning invalid).

However the curl code does the exact same thing and works. I either get the expected string with the url or it says i need to wait (for a few seconds to 1 minute).

Why? whats the difference between the two? It looks very F%^&*ed up that it is behaving differently (its been causing me HOURS of problems).

NOTE: the only cookie required by the site is SID (tested). It holds your session id. The first post activates it and the 2nd command checks the status with the returning json string. Feel free to set the CookieContainer to only use SID if you like.

WARNING: you may want to change SID to a different value so other people arent activating it. Your may want to run the 2nd url to ensure the session id is not used and says expired/invalid before you start.

additional note: with curl or in your browser if you do the POST command you can stick the sid in .NET cookie container and the 2nd command will work. But doing the first command (the POST data) will not work. This post function i have used for many other sites that require post and so far it has worked. Obviously checking the Method is a big deal and i see it is indeed POST when doing the first command.

    static void Main(string[] args)
    {
        var cookie = new CookieContainer();
        PostData("http://uploading.com/files/get/37e36ed8/", "action=second_page&file_id=9134949&code=37e36ed8", cookie);
        Thread.Sleep(4000);
        var res = PostData("http://uploading.com/files/get/?JsHttpRequest=12719362769080-xml&action=get_link&file_id=9134949&code=37e36ed8&pass=undefined",
            null/*this makes it GET*/, cookie);

        Console.WriteLine(res);
        /*
        curl -b "SID=37468830" -A "DUMMY_User_Aggent" -d "action=second_page&file_id=9134949&code=37e36ed8" "http://uploading.com/files/get/37e36ed8/"
        curl -b "SID=37468830" -A "DUMMY_User_Aggent" "http://uploading.com/files/get/?JsHttpRequest=12719362769080-xml&action=get_link&file_id=9134949&code=37e36ed8&pass=undefined"
        */
    }

I am fed up with HttpWebRequest/.NET htto clients. I did it using curl (after learning how to set it up on .NET and refreshing myself). I did it simply and quickly and it WORKED. No stupid problems.

        Curl.GlobalInit((int)CURLinitFlag.CURL_GLOBAL_ALL);
        var curl = new Easy();
        curl.SetOpt(CURLoption.CURLOPT_USERAGENT, "DUMMY_User_Aggent");
        curl.SetOpt(CURLoption.CURLOPT_COOKIE, "SID=4385743");


        curl.SetOpt(CURLoption.CURLOPT_POSTFIELDS, "action=second_page&file_id=9134949&code=37e36ed8");
        curl.SetOpt(CURLoption.CURLOPT_URL, "http://uploading.com/files/get/37e36ed8/");
        curl.Perform();


        curl.SetOpt(CURLoption.CURLOPT_POST, 0);
        Easy.WriteFunction wf = new Easy.WriteFunction(OnWriteData);
        curl.SetOpt(CURLoption.CURLOPT_WRITEFUNCTION, wf);
        curl.SetOpt(CURLoption.CURLOPT_URL, "http://uploading.com/files/get/?JsHttpRequest=12719362769080-xml&action=get_link&file_id=9134949&code=37e36ed8&pass=undefined");
        curl.Perform();

        curl.Cleanup();
        Curl.GlobalCleanup();

解决方案

Apparently you're trying to download something from uploading.com with a program, which is something they don't want you to. Since you aren't sending a UserAgent with cUrl, they have no way of knowing you're automating it, yet .NET will probably send a blacklisted UserAgent.