简体   繁体   English

在C#中打开链接WebBrowser或控制台

[英]Open link WebBrowser or console in C#

I have a problem from the WebBrowser and the terminal in c #, I can not deal with opening the link, 我在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,

response from windows and android browser 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

response from WPF or console 来自WPF或控制台的响应

err 10, Signature value is incorrect

Please help solve the problem 请帮助解决问题

My code 我的密码

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 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>

firewall is disabled, the code seems to be correct, still not working, can cause lies somewhere else? 防火墙已禁用,代码似乎正确,仍然无法正常工作,是否可能导致其他地方说谎?

Visual Studio Express 2013 Visual Studio速成版2013

Your problem is related with \\n in your url string. 您的问题与网址字符串中的\\n有关。

Works 作品

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);

Doesn't work (err 10, Signature value is incorrect) 不起作用(错误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);

All you need is a @ :) 您只需要一个@ :)

See this: String literals 参见: 字符串文字

因此,您所需要的只是用\\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