簡體   English   中英

在C#中打開鏈接WebBrowser或控制台

[英]Open link WebBrowser or console in C#

我在C#中從WebBrowser和終端遇到問題,我無法處理打開鏈接的問題,

string link = "https://ssl.filmweb.pl/api?version=1.0&appId=android&methods=getFilmInfoFull%20[107404]\n&signature=1.0,abbe0aaf4fcc5c56327c977ee07d72b6";

this.webb.Navigate(link, null, null, "User-Agent: ..."); or the same link,

Windows和Android瀏覽器的響應

ok ["Piraci z Karaibów: Skrzynia umarlaka","Pirates of the Caribbean: Dead Man's Chest",7.83812,222891,"Fantasy,Przygodowy",2006,150,119,"http://www.filmweb.pl/Skrzynia.Umarlaka/discussion",1,1,"/74/04/107404/7518098.2.jpg",null,"2006-06-24","2006-07-21",0,0,0,"USA","Jack Sparrow musi spłacić dług zaciągnięty wobec kapitana Latającego Holendra. Uniknie śmierci, gdy znajdzie i zniszczy serce Davy'ego Jonesa ukryte w Skrzyni Umarlaka."] t:43200

來自WPF或控制台的響應

err 10, Signature value is incorrect

請幫助解決問題

我的密碼

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Filmweb
{
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            var webb = new WebBrowser();
            var link = "https://ssl.filmweb.pl/api?version=1.0&appId=android&methods=getFilmInfoFull%20[107404]\n&signature=1.0,abbe0aaf4fcc5c56327c977ee07d72b6";
            this.webb.Navigate(link);
        }
    }
}

XAML

<Window x:Class="Filmweb.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="350" Width="525">
<Grid>
    <WebBrowser x:Name="webb" HorizontalAlignment="Left" Height="319" VerticalAlignment="Top" Width="517"/>

</Grid>

防火牆已禁用,代碼似乎正確,仍然無法正常工作,是否可能導致其他地方說謊?

Visual Studio速成版2013

您的問題與網址字符串中的\\n有關。

作品

var url = @"https://ssl.filmweb.pl/api?version=1.0&appId=android&methods=getFilmInfoFull%20[107404]\n&signature=1.0,abbe0aaf4fcc5c56327c977ee07d72b6";
var res = new WebClient().DownloadString(url);

不起作用(錯誤10,簽名值不正確)

var url = "https://ssl.filmweb.pl/api?version=1.0&appId=android&methods=getFilmInfoFull%20[107404]\n&signature=1.0,abbe0aaf4fcc5c56327c977ee07d72b6";
var res = new WebClient().DownloadString(url);

您只需要一個@ :)

參見: 字符串文字

因此,您所需要的只是用\\n加上斜線來轉義\\n符號: https://ssl.filmweb.pl/api?version=1.0&appId=android&methods=getFilmInfoFull [107404]\\\\n&signature=1.0,abbe0aaf4fcc5c56327c977ee07d72b6 : https://ssl.filmweb.pl/api?version=1.0&appId=android&methods=getFilmInfoFull [107404]\\\\n&signature=1.0,abbe0aaf4fcc5c56327c977ee07d72b6

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM