Click here to Skip to main content
15,921,959 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I'm using following code to get response from php script but it gives me javascript error response instead of script response.

C# Code:
C#
var request = (HttpWebRequest)WebRequest.Create("http://gujaratmovement.rf.gd/testc.php");

            var postData = "test=hello";
            var data = Encoding.ASCII.GetBytes(postData);

            request.Method = "POST";
            request.ContentType = "application/x-www-form-urlencoded";
            request.ContentLength = data.Length;

            using (var stream = request.GetRequestStream())
            {
                stream.Write(data, 0, data.Length);
            }

            var response = (HttpWebResponse)request.GetResponse();

            var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
            richTextBox1.Text = responseString;



Output response:
<html><body><script type="text/javascript" src="/aes.js" ></script><script>function toNumbers(d){var e=[];d.replace(/(..)/g,function(d){e.push(parseInt(d,16))});return e}function toHex(){for(var d=[],d=1==arguments.length&&arguments[0].constructor==Array?arguments[0]:arguments,e="",f=0;f<d.length;f++)e+=(16>d[f]?"0":"")+d[f].toString(16);return e.toLowerCase()}var a=toNumbers("f655ba9d09a112d4968c63579db590b4"),b=toNumbers("98344c2eee86c3994890592585b49f80"),c=toNumbers("b1d5801948be3fab1aaf846da47ba80f");document.cookie="__test="+toHex(slowAES.decrypt(c,2,a,b))+"; expires=Thu, 31-Dec-37 23:55:55 GMT; path=/"; location.href="http://gujaratmovement.rf.gd/testc.php?i=1";</script><noscript>This site requires Javascript to work, please enable Javascript in your browser or use a browser with Javascript support</noscript></body></html>


What I have tried:

I've tried setting user Agent and cookie as suggest online somemwhere.
Posted
Updated 2-Nov-18 6:52am
Comments
Member 14779780 29-Dec-20 8:38am    
You should allow javascript and cookies.

1 solution

The site you're trying to scrape has added that Javascript block to prevent people from doing precisely what you appear to be trying to do - steal their content.

You will either need to talk to the people who run that site to see if there's another way your can access their content, or find another source.
 
Share this answer
 
v2
Comments
MekVala 16-Nov-18 5:12am    
The Site is mine and hosted on shared hosting. How do i disable it?
Richard Deeming 16-Nov-18 6:48am    
Change the code on your site to remove the redirection script, or add a specific end-point for your C# application that just returns the data you want.
Member 14189796 29-Aug-19 7:58am    
I have exactly the same problem as the guy above. I don't have any AES things on the page im trying to send a post request to but still get the error.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900