简体   繁体   中英

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,

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

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

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

<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

Your problem is related with \\n in your url string.

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)

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM