브라우저로 웹 사이트에 액세스하는 데 문제가 없지만 프로그래밍 방식으로 스크래핑을 위해 웹 사이트에 액세스하려고하면 다음 오류가 발생합니다.오류 500 웹 요청으로 웹 사이트를 스크래핑 할 수 없음
The remote server returned an error: (500) Internal Server Error.
다음은 내가 사용하고있는 코드입니다.
using System.Net;
string strURL1 = "http://www.covers.com/index.aspx";
WebRequest req = WebRequest.Create(strURL1);
// Get the stream from the returned web response
StreamReader stream = new StreamReader(req.GetResponse().GetResponseStream());
System.Text.StringBuilder sb = new System.Text.StringBuilder();
string strLine;
// Read the stream a line at a time and place each one
while ((strLine = stream.ReadLine()) != null)
{
if (strLine.Length > 0)
sb.Append(strLine + Environment.NewLine);
}
stream.Close();
이 하나가 저를 곤혹스럽게합니다. TIA
:
는에
UserAgent
속성을 설정하려고합니다. 그들은이 "중학교 프로그래머"를 멈출 수 없었습니다. StackOverflow에 대한 액세스 권한이 있습니다. –