小编Pet*_*ter的帖子

从httpwebrequest获取cookie

我正在尝试使用此代码从网站获取所有Cookie

        CookieContainer cookieJar = new CookieContainer();

        var request = (HttpWebRequest)HttpWebRequest.Create("http://www.foetex.dk/ugenstilbud/Pages/Zmags.aspx");
        request.CookieContainer = cookieJar;

        var response = request.GetResponse();

        foreach (Cookie c in cookieJar.GetCookies(request.RequestUri))
        {
            Console.WriteLine("Cookie['" + c.Name + "']: " + c.Value);
        }

        Console.ReadLine();
Run Code Online (Sandbox Code Playgroud)

我唯一想要的是用console.writeline显示,但我没有得到它们中的一个.

c# cookies

10
推荐指数
2
解决办法
5万
查看次数

Texstudio词库

刚刚安装了TeXStudio,因为我认为它具有比TeXmaker更多的功能.

我无法工作的一件事是词库.我已经从LibreOffice下载并安装了丹麦语词典,但它似乎不起作用.

我试过tex.stackexchange,但没有运气.我认为这是一个错误,或libreoffice的.dat文件中的语法坏了,有人可以告诉它有什么问题,以及如何解决它.

提前致谢.

latex thesaurus

6
推荐指数
2
解决办法
9971
查看次数

获取facebook用户令牌

我试图通过这样做来检索facebook用户令牌.我知道它可以在python中完成.

    public string GetToken(string Username, string Password)
    {
        wb.DownloadData("https://login.facebook.com/login.php?login_attempt=1");
        var data = new NameValueCollection();
        data["email"] = UserName;
        data["pass"] = Password;
        byte[] responsebytes = wb.UploadValues("https://login.facebook.com/login.php?login_attempt=1", "POST", data);
       string responsebody = Encoding.UTF8.GetString(wb.("https://www.facebook.com/dialog/oauth?client_id=282892925078054&redirect_uri=https://www.facebook.com/&response_type=token"));
        Console.WriteLine(responsebody);

        return responsebody;
    }
Run Code Online (Sandbox Code Playgroud)

但它没有返回令牌.我知道它可以做到,因为我已经在python中看到了这一点.还有一种从这里获取用户ID的简单方法吗?

编辑:

这是在python中完成的:

def get_token(self, username, password):
    self.session.get("https://login.facebook.com/login.php?login_attempt=1")
    self.session.post("https://login.facebook.com/login.php?login_attempt=1", data={'email': username, 'pass': password})    
    return self.session.get("https://www.facebook.com/dialog/oauth?client_id=282892925078054&redirect_uri=https://www.facebook.com/&response_type=token").url.split("=")[1].split("&")[0]
Run Code Online (Sandbox Code Playgroud)

好的,我到目前为止.

        //Login to facebook.
        string formUrl = "https://login.facebook.com/login.php?login_attempt=1"; // NOTE: This is the URL the form POSTs to, not the URL of the form (you can find this in the "action" …
Run Code Online (Sandbox Code Playgroud)

c# facebook token

6
推荐指数
1
解决办法
1548
查看次数

从python文件中的ajax post请求获取发布数据

我正在尝试使用ajax post请求发布一些数据并执行python文件,检索python文件中的数据,然后返回结果.

我有以下ajax代码

        $(function () {
                    $("#upload").on("click", function (e) {
                        $.ajax({
                            type: 'post',
                            url: "test1.py",
                            data: {'param1':'abc'},
                            async: false,
                            success: function (response) {
                                console.log(response);
                            }
                        }).done(function (data) {
                            console.log(data);
                        });
                    });
                });
Run Code Online (Sandbox Code Playgroud)

以及以下python文件

    #! /usr/bin/python
    from __future__ import print_function
    import cgi, cgitb
    def index():
        data = cgi.FieldStorage()
        mydata = data['param1'].value
        return return "test"
Run Code Online (Sandbox Code Playgroud)

我在param1上得到了一个关键词 - >"KeyError:'param1'".我也试过使用getValue(data ['param1'].看起来像将ajax调用中的数据传输到我想要执行的python文件的问题......但我无法弄清楚为什么.

提前致谢

python ajax jquery

5
推荐指数
1
解决办法
9010
查看次数

如何使用JsonProperty获取嵌套属性

我正在尝试使用Json.net反序列化此JSON代码.它是关于特定电影的信息.一切都按预期工作,除了cast属性,它嵌套在credits属性中.我为我的班级中的演员制作了一个班级Actor和一个这个演员班的名单Movie.

这是JSON:

{
    "id":550,
    "original_title":"Fight Club",
    "credits":
    {
        "cast":
        [
            {
                "id":819,
                "name":"Edward Norton",
                "character":"The Narrator",
                "order":0,
                "cast_id":4,
                "profile_path":"/eIkFHNlfretLS1spAcIoihKUS62.jpg"
            },
            {
                "id":287,
                "name":"Brad Pitt",
                "character":"Tyler Durden",
                "order":1,
                "cast_id":5,
                "profile_path":"/kc3M04QQAuZ9woUvH3Ju5T7ZqG5.jpg"
            },
            {
                "id":1283,
                "name":"Helena Bonham Carter",
                "character":"Marla Singer",
                "order":2,
                "cast_id":6,
                "profile_path":"/58oJPFG1wefMC0Vj7sFzHPrm67J.jpg"
            },
            {
                "id":7470,
                "name":"Meat Loaf",
                "character":"Robert 'Bob' Paulson",
                "order":3,
                "cast_id":7,
                "profile_path":"/pwNyXgegO1nlZ8uWT847JM8EjGj.jpg"
            },
            {
                "id":7471,
                "name":"Zach Grenier",
                "character":"Richard Chesler",
                "order":4,
                "cast_id":8,
                "profile_path":"/jghYiKdNkVehKpiVyE97AWrU9KQ.jpg"
            },
            {
                "id":7472,
                "name":"Richmond Arquette",
                "character":"Intern",
                "order":5,
                "cast_id":9,
                "profile_path":null
            },
            { …
Run Code Online (Sandbox Code Playgroud)

c# json json.net

3
推荐指数
2
解决办法
4万
查看次数

泛型方法返回nullReferenceException

我有这个通用方法总是返回nullReferenceException.我已经把所有不必要的代码拿出来了,它仍然给我一个例外.

    public T RetrieveInformationFromApi<T>(int Id) where T : IMovie
    {
        T result = default(T);

        result.Title = "test";
     }
Run Code Online (Sandbox Code Playgroud)

可以使用三个不同的类来调用该方法,这三个类都具有属性Title,并且all都实现了接口IMovie,但该方法仍然给我一个例外.我究竟做错了什么?

c# generics methods exception nullreferenceexception

0
推荐指数
1
解决办法
340
查看次数