Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
416 views
in Technique[技术] by (71.8m points)

javascript - 如何防止js文件下载并将返回的传输返回到c#webBrowser?(How can I prevent js file download and return transfer into c# webBrowser?)

I have a script in php for changing ip on my huawei modem.(我在php中有一个脚本可用于更改华为调制解调器上的IP。)

I'm trying to do similar with c# webBrowser.(我正在尝试使用c#webBrowser做类似的事情。) When I login into modem with c#, it throws a js file which is dynamically created (not a static file) and containing some variables.(当我使用c#登录调制解调器时,它将引发一个js文件,该文件是动态创建的(不是静态文件),并且包含一些变量。) Php curl automatical catches the file and returns it.(php curl自动捕获文件并返回。) So I can read and post those variables later.(因此,我以后可以阅读和发布这些变量。) But c# webbrowser returns a file download dialog and my script can't read those variables.(但是c#webbrowser返回文件下载对话框,而我的脚本无法读取这些变量。) How can I do this?(我怎样才能做到这一点?) curl_setopt($ch, CURLOPT_URL, "http://192.168.1.1/api/system/user_login"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); This is php way of doing it.(这是php的方法。) And I can read the file with(我可以用读取文件) $response = curl_exec($ch); But c# form with webBrowser asks me to download a file named "user_login817dc01f.js" (file name and contents are changing everytime).(但是带有webBrowser的c#表格要求我下载一个名为“ user_login817dc01f.js”的文件(文件名和内容每次都在更改)。) Content is like this:(内容是这样的:) while(1); /*{"csrf_param":"W4A1th4QkgshQIJMzK7f0mg0rpzMd8m","csrf_token":"iR00ua1IVxD4jsVFmWSYttBYpP346Rn","Cat":"ok","level":2,"IsWizard":true,"IsFirst":true}*/ 华为登录文件 Those lines means I'm in router successfully.(这些行表示我已成功进入路由器。) But my c# script needs to read those strings so I can create variables with them and do a final https post for restarting pppoe.(但是我的c#脚本需要读取这些字符串,因此我可以使用它们创建变量,并为重新启动pppoe做最后的https发布。) How can I prevent js file download and return transfer into c# webBrowser so I could get page contents with "webBrowser1.DocumentText" property?(如何防止js文件下载并返回传输到c#webBrowser中,以便可以使用“ webBrowser1.DocumentText”属性获取页面内容?)   ask by digiogi translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

Please log in or register to answer this question.

Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...