上海经常被戏称为魔都,那么上海魔在哪里呢?我们可以从两层方面去解释。第一是魔力,第二是魔幻。 魔力是指上海是我国的金融中心,是我国经济总量第一的城市,人均收入是排在第一位的,是我国进出口贸易第一的城市,也是我国最开放的城市之一。拼多多、B站等知名互联网公司的总部都在上海,腾讯、阿里、头条等在上海都有办公部门。每年吸引着无数打工人来上海追寻梦想。再说魔幻,上海是一座奇迹之城,历史的传承和发展速度的惊人都令人不得不赞叹。 那么去上海的旅游攻略是什么呢?上海知名度最高的旅游景点,应该是上海外滩,东方明珠电视塔,以及迪士尼乐园还有一些其他的景点也是值得一去的好地方。这么多的景点?该如何规划呢?下面我们利用python获取一份旅游攻略,希望可以帮助到有需要的你。 - // 要访问的目标页面
- string targetUrl = "https://www.ly.com/";
- // 代理服务器(产品官网 www.16yun.cn)
- string proxyHost = " u1099.30.tn.16yun.cn";
- string proxyPort = "31111";
- // 代理验证信息
- string proxyUser = "16RJETQM";
- string proxyPass = "767057";
- // 设置代理服务器
- WebProxy proxy = new WebProxy(string.Format("{0}:{1}", proxyHost, proxyPort), true);
- ServicePointManager.Expect100Continue = false;
- var request = WebRequest.Create(targetUrl) as HttpWebRequest;
- request.AllowAutoRedirect = true;
- request.KeepAlive = true;
- request.Method = "GET";
- request.Proxy = proxy;
- //request.Proxy.Credentials = CredentialCache.DefaultCredentials;
- request.Proxy.Credentials = new System.Net.NetworkCredential(proxyUser, proxyPass);
- // 设置Proxy Tunnel
- // Random ran=new Random();
- // int tunnel =ran.Next(1,10000);
- // request.Headers.Add("Proxy-Tunnel", String.valueOf(tunnel));
- //request.Timeout = 20000;
- //request.ServicePoint.ConnectionLimit = 512;
- //request.UserAgent = "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.82 Safari/537.36";
- //request.Headers.Add("Cache-Control", "max-age=0");
- //request.Headers.Add("DNT", "1");
- //String encoded = System.Convert.ToBase64String(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(proxyUser + ":" + proxyPass));
- //request.Headers.Add("Proxy-Authorization", "Basic " + encoded);
- using (var response = request.GetResponse() as HttpWebResponse)
- using (var sr = new StreamReader(response.GetResponseStream(), Encoding.UTF8))
- {
- string htmlStr = sr.ReadToEnd();
复制代码
今天的分享就到这里,有需要的具体的攻略的小伙伴留言获取呀。
|