2017-07-14 7 views
0

VB.NETを使用してFacebookページからビジネスデータを抽出しようとしています。しかし、私は期待していた回答を得られません。私は応答のテキストを見ればHttpRequestとHttpResponseを使用してFacebookページからデータを抽出する

Dim request As HttpWebRequest 
Dim response As HttpWebResponse 
Dim responseText As String 

request = CType(WebRequest.Create(http://www.facebook.com/Microsoft)) 
request.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)" 
request.AllowAutoRedirect = True 

response = CType(request.GetResponse(), HttpWebResponse) 

私はこれを取得:私はWebBrowserコントロールを使用する場合

<html><head><title>Redirecting...</title><script>__DEV__=0;_script_path = "XVanityURLController";var uri_re=/^(?:(?:[^:\/?#]+):)?(?:\/\/(?:[^\/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?/,target_domain='';window.location.href.replace(uri_re,function(a,b,c,d){var e,f,g;e=f=b+(c?'?'+c:'');if(d){d=d.replace(/^(!|%21)/,'');g=d.charAt(0);if(g=='/'||g=='\\')e=d.replace(/^[\\\/]+/,'/');}if(e!=f)window.location.replace(target_domain+e);});</script><script type="text/javascript">/*<![CDATA[*/(function(){function si_cj(m){setTimeout(function(){new Image().src="https:\/\/error.facebook.com\/common\/scribe_endpoint.php?c=si_clickjacking&t=956"+"&m="+m;},5000);}if(top!=self && !false){try{if(parent!=top){throw 1;}var si_cj_d=["apps.facebook.com","apps.beta.facebook.com"];var href=top.location.href.toLowerCase();for(var i=0;i<si_cj_d.length;i++){if (href.indexOf(si_cj_d[i])>=0){throw 1;}}si_cj("3 ");}catch(e){si_cj("1 \t");window.document.write("\u003Cstyle>body * {display:none !important;}\u003C\/style>\u003Ca href=\"#\" onclick=\"top.location.href=window.location.href\" style=\"display:block !important;padding:10px\">Go to Facebook.com\u003C\/a>");/*kSxhSBR_*/}}}())/*]]>*/</script><script>window.location.replace("https:\/\/m.facebook.com\/AMD");</script><meta http-equiv="refresh" content="0;url=https://m.facebook.com/AMD" /></head><body></body></html> 

はしかし、それは実際には、Microsoftのページに私をリダイレクトします。私はこれを達成するためにフォームを使用したくない。

したがって、私はこのリダイレクトをHttpWebRequestで回避する方法がわかりません。私は何とかFacebookにログインして私が探している回答を得る必要がありますか?もしそうなら、私はこれをどのようにするのですか?助けてください、私は数日間この頭を叩いています。


##

+1

本当に適切なAPIを使用する必要があります。ページ、特にFacebookページのスクラップは、信頼性がありません。 – Brad

+0

...またToSに対しても – CBroe

答えて

1

ページには、リダイレクトを実行するためにはJavaScriptを使用しています。

あなたのHttpResponseがHTMLを文字列として返していますが、内部でJavaScriptを実行しません。

SeleniumなどのヘッドレスWebブラウザの使用を検討してください。

関連する問題