How to get PDF from http request/response stream - c#

I have a url like this "https://site.com/cgi-bin/somescript.pl?file=12345.pdf&type=application/pdf". When i go to this url it will dispaly an pdf in my browser in an iframe. Is it possible to save this pdf? I am thinking of getting the http response stream and dump it into a file. Please advice. Thanks.

Something like this would work
const string FILE_PATH = "C:\\foo.pdf";
const string DOWNLOADER_URI = "https://site.com/cgi-bin/somescript.pl?file=12345.pdf&type=application/pdf";
using (var writeStream = File.OpenWrite(FILE_PATH))
{
var httpRequest = WebRequest.Create(DOWNLOADER_URI) as HttpWebRequest;
var httpResponse = httpRequest.GetResponse();
httpResponse.GetResponseStream().CopyTo(writeStream);
writeStream.Close();
}

Related

Getting the HTML code of a webpage

I am trying to get the HTML code of a webpage using it's url. I have written the following code, it works, but comparing the resulting string it doesn't match the code I see when I use google chrome's inspect. I am not an HTML gru, but it seems to be different.
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://fantasy.premierleague.com/a/leagues/standings/517292/classic");
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
StreamReader stream = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding(response.CharacterSet));
string PageScript = stream.ReadToEnd();
The resulting script is as follows: https://ideone.com/DXzfKy
I am using those two lines to set the security protocol
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
If someone can tell me what am I looking at and what might be wrong, I will be grateful.
All you need to do is to create an instance of a WebClient and using that you can read the data from URI, than convert it into StreamReader and finally in Plain Text Format.
WebClient client = new WebClient();
Stream dataFromPage = client.OpenRead(new Uri("https://ideone.com/DXzfKy"));
StreamReader reader = new StreamReader(dataFromPage);
string htmlContent = reader.ReadToEnd();

How to use get_video_info Youtube

I'm trying to develop a Youtube downloader.I need video mp4 stream urls and im trying to use get_video info check my source code
WebRequest req = HttpWebRequest.Create("https://www.youtube.com/get_video_info?video_id=" + videoid +"&el=embedded&ps=default&eurl=&gl=US&hl=en");
WebResponse webResp = req.GetResponse();
StreamReader sr = new StreamReader(webResp.GetResponseStream(), System.Text.Encoding.UTF8);
string data = sr.ReadToEnd();
sr.Close();
webResp.Close();
This codes always get just a part of data maybe half.After decoding data just looks like this
length_seconds=459&sffb=True&no_get_video_log=1&hl=en_US&vmap=<?xml+version="1.0"+encoding="UTF-8"?><vmap:VMAP+xmlns:vmap="http://www.iab.net/videosuite/vmap"+xmlns:yt="http://youtube.com"+version="1.0"><vmap:AdBreak+breakType="linear"+timeOffset="start"><vmap:AdSource+allowMultipleAds+=+"false"><vmap:VASTData><VAST+version="3.0"><Ad><Wrapper><AdSystem+version="1">YT:AdSense</AdSystem><VASTAdTagURI><![CDATA[https://googleads.g.doubleclick.net/pagead/ads?ad_type=text_image&channel=Vertical_1021+Vertical_1036+Vertical_1408+Vertical_211+Vertical_36+Vertical_590+Vertical_613+afv_overlay+afv_user_id_IO0szsIo5AKIFmbbhfxFqw+afv_user_lundgrenrob+invideo_overlay_480x70_cat10+yt_cid_679125+yt_mpvid_xxV6hpjhJlzWVUm7+yt_no_360+yt_no_3pas+yt_no_ap+yt_no_cp+yt_no_wa+ytdevice_1+ytdevicever_1.20170712+ytel_embedded+ytps_default&client=ca-pub-6219811747049371&dbp=ChZoWFduSWZZN2VpcG9CaWVYWnBPSndBEAEgASgA&description_url=http://www.youtube.com/video/rzkoQFbzmOk&eid=148648206&hl=en&host=ca-host-pub-7533488853144487&ht_id=5547539&loeid=9413138,9422596,9431012,9434289,9441394,9444433,9444893,9450707,9451825,9460350,9463578,9465813,9475121,9475579,9476699,9478199,9478523,9479324,9480114,9480538,9481125,9481317,9482504,9482602,9482851,9483147,9483258,9483501&osd=2&pucrd=CgYIABAAGAA&sdki=18803DAD&url=http://www.youtube.com/video/rzkoQFbzmOk&videoad_start_delay=0&v_p=JY0c2kM=&ytdevice=1&ytdevicever=1.20170712&yt_pt=APb3F2_FMmSD8mG8PMmMq7urTSbmCkJ0Bga4WDpKEQV0vAboVlPPijEHbExGYSXuMBmFcOJpCrpa2LhYnrkbgQbnWXXOarZjCKizS68OiIqOlB2GrZui5-ggUQ6aT7w6CaS_ifnYBnZXHpId9iX76vg6ufeyBrm43Pn8XtzfKSqvqvC1W8CRVv5me3zlMAU8-o1WblaDrL0g1b7SL7ot8DDGof6LRYQvNLPRCMZ6cjjIRMd62t7yetC6yMM2gjL_wZnSM_yKWhGZZgCWLQpIGY40tHARFRtOCCQsri5ttw&yt_vis=0]]></VASTAdTagURI><Impression><![CDATA[https://www.youtube.com/api/stats/ads?ver=2&ns=1&event=2&device=1&content_v=rzkoQFbzmOk&el=embedded&ei=om5qWfj6NYL_WNjYpIAD&devicever=1.20170712&asr=CgA&format=[FORMAT_NAMESPACE]_[FORMAT_TYPE]_[FORMAT_SUBTYPE]&break_type=[BREAK_TYPE]&conn=[CONN]&cpn=[CPN]&lact=[LACT]&m_pos=[MIDROLL_POS]&mt=[MT]&p_h=[P_H]&p_w=[P_W]&rwt=[RWT]&sdkv=[SDKV]&slot_pos=[SLOT_POS]&vis=[VIS]&vol=[VOL]&wt=[WT]&ad_cpn=[AD_CPN]&ad_id=[AD_ID]&ad_len=[AD_LEN]&ad_mt=[AD_MT]&ad_sys=[AD_SYS]&ad_v=[AD_V]&aqi=]]></Impression><Error><![CDATA[https://www.youtube.com/api/stats/ads?ver=2&ns=1&event=5&device=1&content_v=rzkoQFbzmOk&el=embedded&ei=om5qWfj6NYL_WNjYpIAD&devicever=1.20170712&format=[FORMAT_NAMESPACE]_[FORMAT_TYPE]_[FORMAT_SUBTYPE]&break_type=[BREAK_TYPE]&conn=[CONN]&cpn=[CPN]&lact=[LACT]&m_pos=[MIDROLL_POS]&mt=[MT]&p_h=[P_H]&p_w=[P_W]&rwt=[RWT]&sdkv=[SDKV]&slot_pos=[SLOT_POS]&vis=[VIS]&vol=[VOL]&wt=[WT]&ad_cpn=[AD_CPN]&ad_id=[AD_ID]&ad_len=[AD_LEN]&ad_mt=[AD_MT]&ad_sys=[AD_SYS]&ad_v=[AD_V]&blocking_error=[BLOCKING_ERROR]&error_msg=[ERROR_MSG]&ima_error=[IMA_ERROR]&internal_id=[INTERNAL_ID]&error_code=[YT_ERROR_CODE]&aqi=]]></Error><Creatives><Creative><NonLinearAds><TrackingEvents><Tracking+event="close"><![CDATA[https://www.youtube.com/api/stats/ads?ver=2&ns=1&event=4&device=1&content_v=rzkoQFbzmOk&el=embedded&ei=om5qWfj6NYL_WNjYpIAD&devicever=1.20170712&format=[FORMAT_NAMESPACE]_[FORMAT_TYPE]_[FORMAT_SUBTYPE]&break_type=[BREAK_TYPE]&conn=[CONN]&cpn=[CPN]&lact=[LACT]&m_pos=[MIDROLL_POS]&mt=[MT]&p_h=[P_H]&p_w=[P_W]&rwt=[RWT]&sdkv=[SDKV]&slot_pos=[SLOT_POS]&vis=[VIS]&vol=[VOL]&wt=[WT]&ad_cpn=[AD_CPN]&ad_id=[AD_ID]&ad_mt=[AD_MT]&ad_sys=[AD_SYS]&ad_v=[AD_V]&i_x=[I_X]&i_y=[I_Y]&aqi=]]></Tracking></TrackingEvents><NonLinear><NonLinearClickTracking><![CDATA[https://www.youtube.com/api/stats/ads?ver=2&ns=1&event=6&device=1&content_v=rzkoQFbzmOk&el=embedded&ei=om5qWfj6NYL_WNjYpIAD&devicever=1.20170712&format=[FORMAT_NAMESPACE]_[FORMAT_TYPE]_[FORMAT_SUBTYPE]&break_type=[BREAK_TYPE]&conn=[CONN]&cpn=[CPN]&lact=[LACT]&m_pos=[MIDROLL_POS]&mt=[MT]&p_h=[P_H]&p_w=[P_W]&rwt=[RWT]&sdkv=[SDKV]&slot_pos=[SLOT_POS]&vis=[VIS]&vol=[VOL]&wt=[WT]&ad_cpn=[AD_CPN]&ad_id=[AD_ID]&ad_len=[AD_LEN]&ad_mt=[AD_MT]&ad_sys=[AD_SYS]&ad_v=[AD_V]&i_x=[I_X]&i_y=[I_Y]&aqi=[AQI]]]></NonLinearClickTracking></NonLinear></NonLinearAds></Creative></Creatives><Extensions><Extension+type="waterfall"+fallback_index="1"/><Extension+type="activeview"><CustomTracking><Tracking+event="viewable_impression"><![CDATA[https://www.youtube.com/api/stats/ads?ver=2&ns=1&event=11&device=1&content_v=rzkoQFbzmOk&el=embedded&ei=om5qWfj6NYL_WNjYpIAD&devicever=1.20170712&format=[FORMAT_NAMESPACE]_[FORMAT_TYPE]_[FORMAT_SUBTYPE]&break_type=[BREAK_TYPE]&conn=[CONN]&cpn=[CPN]&lact=[LACT]&m_pos=[MIDROLL_POS]&mt=[MT]&p_h=[P_H]&p_w=[P_W]&rwt=[RWT]&sdkv=[SDKV]&slot_pos=[SLOT_POS]&vis=[VIS]&vol=[VOL]&wt=[WT]&ad_cpn=[AD_CPN]&ad_id=[AD_ID]&ad_len=[AD_LEN]&ad_mt=[AD_MT]&ad_sys=[AD_SYS]&ad_v=[AD_V]&aqi=]]></Tracking></CustomTracking></Extension></Extensions></Wrapper></Ad></VAST></vmap:VASTData></vmap:AdSource><vmap:TrackingEvents><vmap:Tracking+event="error"><![CDATA[https://www.youtube.com/api/stats/ads?ver=2&ns=1&event=1&device=1&content_v=rzkoQFbzmOk&el=embedded&ei=om5qWfj6NYL_WNjYpIAD&devicever=1.20170712&break_type=[BREAK_TYPE]&conn=[CONN]&cpn=[CPN]&lact=[LACT]&m_pos=[MIDROLL_POS]&mt=[MT]&p_h=[P_H]&p_w=[P_W]&rwt=[RWT]&sdkv=[SDKV]&slot_pos=[SLOT_POS]&vis=[VIS]&vol=[VOL]&wt=[WT]]]></vmap:Tracking></vmap:TrackingEvents><vmap:Extensions><vmap:Extension+type="YouTube"><yt:BreakProperty+break_type="BREAK_TYPE_PRE_ROLL"/></vmap:Extension></vmap:Extensions></vmap:AdBreak><vmap:AdBreak+breakType="linear"+timeOffset="end"><vmap:AdSource+allowMultipleAds+=+"false"><vmap:AdTagURI><![CDATA[https://www.youtube.com/get_midroll_info?ei=om5qWfj6NYL_WNjYpIAD&m_pos=-1&index=1&token=AHArUmCi7IgSemIU1zQ6mZwxAcXsVLNJRz6p3BHXmckVo5VKctFqc4x6ksXsbH17HJT9kg5rEKPeTdDjb8Futt8whSRi64lqWuqukgtn7FROGCnEcb9nflpkqnys0RH7G3Felht1tx5IPbpnRh6iSc3pfhsvMMPvQRMUmRuozIyIZp7xVwhrQeYReh0leKubfaqXPRTWIGKf2u-2G082rpE8bhBTdY-ZINFWZXRhW3QAe2N9VTy4wbPGvNo7KAQ2qdBIoMJoJ9-LKEkHoensql4QkA8b3tQb9lJylNiD7N6DG4OQM0gGUrTW0xabLI-NLmeGOeRTCKr-&ad_block=[AD_BLOCK]&cpn=[CPN]&lact=[LACT]&tsla=[TSLA]&vis=[VIS]&c=WEB&cver=1.20170712]]></vmap:AdTagURI></vmap:AdSource><vmap:TrackingEvents><vmap:Tracking+event="error"><![CDATA[https://www.youtube.com/api/stats/ads?ver=2&ns=1&event=1&device=1&content_v=rzkoQFbzmOk&el=embedded&ei=om5qWfj6NYL_WNjYpIAD&devicever=1.20170712&break_type=[BREAK_TYPE]&conn=[CONN]&cpn=[CPN]&lact=[LACT]&m_pos=[MIDROLL_POS]&mt=[MT]&p_h=[P_H]&p_w=[P_W]&rwt=[RWT]&sdkv=[SDKV]&slot_pos=[SLOT_POS]&vis=[VIS]&vol=[VOL]&wt=[WT]]]></vmap:Tracking></vmap:TrackingEvents><vmap:Extensions><vmap:Extension+type="YouTube"><yt:BreakProperty+break_type="BREAK_TYPE_POST_ROLL"/></vmap:Extension></vmap:Extensions></vmap:AdBreak><vmap:Extensions><vmap:Extension+type="YouTube"><TrackingDecoration+match="^https?://((([a-z][a-z0-9.-]*\.)?(youtube|corp\.google).com/api/stats/ads)|((www\.)?youtube\.com/pagead/psul))"+headers="device,user"/><TrackingMacro+match="^https?://(secure\-uat\-dpr\.imrworldwide|secure\-gg\.imrworldwide|g\.scorecardresearch)\.com/"+macros="device_id"/><RegexUriMacroValidator><MacroToRegexUris+macro="NIELSEN_DEVICE_ID"><RegexUri+value="^https?://(secure\-uat\-dpr\.imrworldwide|secure\-gg\.imrworldwide|g\.scorecardresearch)\.com/"/></MacroToRegexUris><MacroToRegexUris+macro="COMSCORE_DEVICE_ID"><RegexUri+value="^https?://(secure\-uat\-dpr\.imrworldwide|secure\-gg\.imrworldwide|g\.scorecardresearch)\.com/"/></MacroToRegexUris><MacroToRegexUris+macro="MOAT_INIT"><RegexUri+value="^https?://yts\.moatads\.com"/><RegexUri+value="^https?://yts-testing\.moatads\.com"/><RegexUri+value="^https?://pagead2\.googlesyndication\.com/pagead/gen_204"/></MacroToRegexUris><MacroToRegexUris+macro="MOAT_VIEWABILITY"><RegexUri+value="^https?://[^.]*\.moatads\.com"/><RegexUri+value="^https?://pagead2\.googlesyndication\.com/pagead/gen_204"/><RegexUri+value="^https?://pubads\.g\.doubleclick\.net"/></MacroToRegexUris><MacroToRegexUris+macro="IAS_VIEWABILITY"><RegexUri+value="^https?://pm\.adsafeprotected\.com/youtube"/><RegexUri+value="^https?://pm\.test-adsafeprotected\.com/youtube"/><RegexUri+value="^https?://pagead2\.googlesyndication\.com/pagead/gen_204"/><RegexUri+value="^https?://pubads\.g\.doubleclick\.net"/></MacroToRegexUris><MacroToRegexUris+macro="DV_VIEWABILITY"><RegexUri+value="^https?://e[0-9]+\.yt\.srs\.doubleverify\.com"/><RegexUri+value="^https?://pagead2\.googlesyndication\.com/pagead/gen_204"/><RegexUri+value="^https?://pubads\.g\.doubleclick\.net"/></MacroToRegexUris><MacroToRegexUris+macro="GOOGLE_VIEWABILITY"><RegexUri+value="^https?://pagead2\.googlesyndication\.com"/><RegexUri+value="^https?://pubads\.g\.doubleclick\.net"/><RegexUri+value="^https?://googleads\.g\.doubleclick\.net"/><RegexUri+value="^https?://([a-z0-9]+\.)*youtube\.com"/><RegexUri+value="^https?://ad[\.-]([a-z0-9]+\.){0,1}doubleclick\.net"/><RegexUri+value="^https?://ade\.googlesyndication\.com"/></MacroToRegexUris></RegexUriMacroValidator></vmap:Extension></vmap:Extensions></vmap:VMAP>&encoded_ad_safety_reason=CgA&thumbnail_url=https://i.ytimg.com/vi/rzkoQFbzmOk/default.jpg&innertube_api_key=AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8&atc=a=3&b=32vy80AGa-Bgh5X78MGIbmu2Kto&c=1500147363&d=1&e=rzkoQFbzmOk&c3a=26&c1a=1&c6a=1&hh=1HDgx0VAJl0SXzxb45QsrH_lAKVbaJ_K7iaF7J_ogxg&iv_load_policy=1&fade_out_start_milliseconds=0&instream_long=False&avg_rating=4.95149946213&of=hXWnIfY7eipoBieXZpOJwA&ismb=4450000&xhr_apiary_host=youtubei.youtube.com&loeid=9413138,9422596,9431012,9434289,9441394,9444433,9444893,9450707,9451825,9460350,9463578,9465813,9475121,9475579,9476699,9478199,9478523,9479324,9480114,9480538,9481125,9481317,9482504,9482602,9482851,9483147,9483258,9483501&enablecsi=1&account_playback_token=QUFFLUhqbG5Ta1k2bjVZNXE1S1RjeXJma0dYOVhJTlgtUXxBQ3Jtc0trRmxkREVqN1pxcjVPNTB3UUFxOG13RTNoVG1UQ0t4bDFNM3ZyQXhHbGtRQ1FyaWNYSGttZXlVTktEeGc3clQwNkFBNy1Bb08zTEJ6TDZNYkxWN2dwR1JfTWlQbnEyTE9DdDdNNUNGT1pTX3BrZU5aTQ==&fade_in_start_milliseconds=-3000&relative_loudness=0.760999679565&afv_ad_tag=https://googleads.g.doubleclick.net/pagead/ads?ad_type=text_image&channel=Vertical_1021+Vertical_1036+Vertical_1408+Vertical_211+Vertical_36+Vertical_590+Vertical_613+afv_overlay+afv_user_id_IO0szsIo5AKIFmbbhfxFqw+afv_user_lundgrenrob+invideo_overlay_480x70_cat10+yt_cid_679125+yt_mpvid_xxV6hpjhJlzWVUm7+yt_no_360+yt_no_3pas+yt_no_ap+yt_no_cp+yt_no_wa+ytdevice_1+ytdevicever_1.20170712+ytel_embedded+ytps_default&client=ca-pub-6219811747049371&dbp=ChZoWFduSWZZN2VpcG9CaWVYWnBPSndBEAEgASgA&description_url=http://www.youtube.com/video/rzkoQFbzmOk&eid=148648206&hl=en&host=ca-host-pub-7533488853144487&ht_id=5547539&loeid=9413138,9422596,9431012,9434289,9441394,9444433,9444893,9450707,9451825,9460350,9463578,9465813,9475121,9475579,9476699,9478199,9478523,9479324,9480114,9480538,9481125,9481317,9482504,9482602,9482851,9483147,9483258,9483501&osd=2&pucrd=CgYIABAAGAA&sdki=18803DAD&url=http://www.youtube.com/video/rzkoQFbzmOk&v_p=JY0c2kM=&ytdevice=1&ytdevicever=1.20170712&yt_pt=APb3F2_FMmSD8mG8PMmMq7urTSbmCkJ0Bga4WDpKEQV0vAboVlPPijEHbExGYSXuMBmFcOJpCrpa2LhYnrkbgQbnWXXOarZjCKizS68OiIqOlB2GrZui5-ggUQ6aT7w6CaS_ifnYBnZXHpId9iX76vg6ufeyBrm43Pn8XtzfKSqvqvC1W8CRVv5me3zlMAU8-o1WblaDrL0g1b7SL7ot8DDGof6LRYQvNLPRCMZ6cjjIRMd62t7yetC6yMM2gjL_wZnSM_yKWhGZZgCWLQpIGY40tHARFRtOCCQsri5ttw&yt_vis=0&is_listed=1&cafe_experiment_id=148648206&mpvid=xxV6hpjhJlzWVUm7&cver=1.20170712&ptchn=IO0szsIo5AKIFmbbhfxFqw&fade_in_duration_milliseconds=1000&video_id=rzkoQFbzmOk&allow_html5_ads=1&dbp=Ch4KFmhYV25JZlk3ZWlwb0JpZVhacE9Kd0EQASABKAAQARgC&as_launched_in_country=1&iv_invideo_url=https://www.youtube.com/annotations_invideo?cap_hist=1&video_id=rzkoQFbzmOk&client=1&ei=om5qWfj6NYL_WNjYpIAD&csi_page_type=embed&keywords=rob+lundgren,cover,rock,metal,voice,vocal,live+vocal,lundgren,robin+lundgren,robin,nothing+else+matters,metallica,nem,nothing+else+matters+cover,acoustic+cover,n.e.m.,nem+cover,nothing+else+matters+acoustic+cover,metallica+cover,black+album&eventid=om5qWfj6NYL_WNjYpIAD&iv3_module=1&cr=US&root_ve_type=27240&cid=679125&fexp=9413138,9422596,9431012,9434289,9441394,9444433,9444893,9446364,9449243,9450707,9453897,9457141,9458230,9463578,9463594,9465813,9466793,9466795,9466797,9467217,9468797,9468799,9468805,9475121,9475579,9476699,9477080,9478199,9478523,9479324,9480114,9480475,9480538,9481125,9481317,9482504,9482602,9482648,9483147,9483258,9483501&innertube_context_client_version=1.20170712&author=Rob+Lundgren+Live+Vocals&cl=161729798&apiary_host=&allow_embed=1&ppv_remarketing_url=https://www.googleadservices.com/pagead/conversion/971134070/?backend=innertube&cname=1&cver=1_20170712&data=backend=innertube;cname=1;cver=1_20170712;dactive=None;dynx_itemid=rzkoQFbzmOk;ptype=ppv&label=iuZUCLmC72YQ9qiJzwM&ptype=ppv&token=1&swf_player_response=1&idpj=-9&fmt_list=22/1280x720/9/0/115,43/640x360/99/0/0,18/640x360/9/0/115,36/320x180/99/1/0,17/176x144/99/1/0&probe_url=https://r5---sn-q4f7sn76.googlevideo.com/videogoodput?id=o-AEixTmbMug2neWtp5U1Tb-21J9uJ59IBSUY4nJ2T0axm&source=goodput&range=0-4999&expire=1500150962&ip=95.14.68.108&ms=pm&mm=35&pl=24&nh=IgpwZjAyLmRmdzA2Kgs2Ni4xMTAuNTcuNQ&sparams=id,source,range,expire,ip,ms,mm,pl,nh&signature=147AA9BCF3169578802C44A7735BBB7926C37092.5C2597F4730C259D6DDCD8AAAB093C906A61E8AB&key=cms1&itct=CAEQu2kiEwj407O1hIzVAhWCPxYKHVgsCTAo6NQB&shortform=True&t=1&watermark=,https://s.ytimg.com/yts/img/watermark/youtube_watermark-vflHX6b6E.png,https://s.ytimg.com/yts/img/watermark/youtube_hd_watermark-vflAzLcD6.png&host_language=en&excluded_ads=46=14_14;59=14_14;61=1_3,2_3;64=14_14;65=15_2,15_2_1,15_2_4,17_2,17_2_1;84=1_1,1_2,1_2_1,1_3,2_2,2_2_1,2_2_4,2_3,15_2,15_2_1,15_2_4,17_2,17_2_1;89=2_2,15_2;94=15_2,15_2_1,15_2_4,17_2,17_2_1&title=NOTHING+ELSE+MATTERS+(Live+Vocal+&+Acoustic+Cover)&innertube_api_version=v1&allow_ratings=1&pltype=content&ptk=BroadbandTV_Music&csn=om5qWfj6NYL_WNjYpIAD&oid=3q6zKQH3OljiViOJ67PJOw&status=ok&allow_below_the_player_companion=True&loudness=-20.2390003204&ad_slots=0,-1&url_encoded_fmt_stream_map=type=video/mp4;+codecs="avc1.64001F,+mp4a.40.2"&itag=22&quality=hd720&url=https://r1---sn-4g5e6nls.googlevideo.com/videoplayback?ei=om5qWfj6NYL_WNjYpIAD&lmt=1497979410219532&key=yt6&initcwndbps=556250&ipbits=0&mv=m&source=youtube&expire=1500168963&mn=sn-4g5e6nls&ratebypass=yes&mt=1500147287&pl=21&itag=22&ms=au&requiressl=yes&mime=video/mp4&id=o-AIlu0RkrqMnKv9EvUKiHDF8r6kAlczSgWVujKgm6Rz4V&dur=458.570&mm=31&ip=95.14.68.108&signature=5E6066364965F76E6BC61052DC402531E5F319B2.A3BBC0015021650C424E050CD546133A23578F5B&sparams=dur,ei,id,initcwndbps,ip,ipbits,itag,lmt,mime,mm,mn,ms,mv,pl,ratebypass,requiressl,source,expire,type=video/webm;+codecs="vp8.0,+vorbis"&itag=43&quality=medium&url=https://r1---sn-4g5e6nls.googlevideo.com/videoplayback?ei=om5qWfj6NYL_WNjYpIAD&key=yt6&initcwndbps=556250&expire=1500168963&ratebypass=yes&clen=48022685&source=youtube&signature=771D35EFBBDC827F178E06B5B40372EA337A7E9F.6E06C0E37004690B1BF766340415170E296378ED&lmt=1497816143039353&ipbits=0&mv=m&gir=yes&mt=1500147287&pl=21&itag=43&ms=au&requiressl=yes&mime=video/webm&id=o-AIlu0RkrqMnKv9EvUKiHDF8r6kAlczSgWVujKgm6Rz4V&dur=0.000&mm=31&ip=95.14.68.108&mn=sn-4g5e6nls&sparams=clen,dur,ei,gir,id,initcwndbps,ip,ipbits,itag,lmt,mime,mm,mn,ms,mv,pl,ratebypass,requiressl,source,expire,type=video/mp4;+codecs="avc1.42001E,+mp4a.40.2"&itag=18&quality=medium&url=https://r1---sn-4g5e6nls.googlevideo.com/videoplayback?ei=om5qWfj6NYL_WNjYpIAD&key=yt6&initcwndbps=556250&expire=1500168962&ratebypass=yes&clen=42156239&source=youtube&signature=B20E84210DACE3069FC90109B0B4CCD229468AD2.C02B2E5EF9C162E4E2201DA9062571FC6D511010&lmt=1497979373206161&ipbits=0&mv=m&gir=yes&mt=1500147287&pl=21&itag=18&ms=au&requiressl=yes&mime=video/mp4&id=o-AIlu0RkrqMnKv9EvUKiHDF8r6kAlczSgWVujKgm6Rz4V&dur=458.570&mm=31&ip=95.14.68.108&mn=sn-4g5e6nls&sparams=clen,dur,ei,gir,id,initcwndbps,ip,ipbits,itag,lmt,mime,mm,mn,ms,mv,pl,ratebypass,requiressl,source,expire,type=video/3gpp;+codecs="mp4v.20.3,+mp4a.40.2"&itag=36&quality=small&url=https://r1---sn-4g5e6nls.googlevideo.com/videoplayback?ei=om5qWfj6NYL_WNjYpIAD&key=yt6&initcwndbps=556250&expire=1500168963&clen=12684319&source=youtube&signature=384C051D8C33CEFB6E28062E460398765AB5680D.265633CF03B2E0ED7DC72A3C6F3B788D6E10FEF1&lmt=1497814285338647&ipbits=0&mv=m&gir=yes&mt=1500147287&pl=21&itag=36&ms=au&requiressl=yes&mime=video/3gpp&id=o-AIlu0RkrqMnKv9EvUKiHDF8r6kAlczSgWVujKgm6Rz4V&dur=458.640&mm=31&ip=95.14.68.108&mn=sn-4g5e6nls&sparams=clen,dur,ei,gir,id,initcwndbps,ip,ipbits,i...e&html5_subsegment_readahead_target_buffer_health_secs=0.5&report_promotes_terrorism_mobile_web=true&html5_disable_move_pssh_to_moov=true&html5_max_av_sync_drift=50&enable_playlist_multi_season=true&html5_suspend_manifest_on_pause=true&show_countdown_on_bumper=true&html5_always_reload_on_403=true&html5_repredict_interval_secs=0.0&signed_out_notifications_inbox=true&stop_using_ima_sdk_gpt_request_activity=true&kids_mqb_use_confirmed_safe_videos_only=true&html5_new_fallback=true&html5_subsegment_readahead_timeout_secs=2.0&android_native_live_enablement=true&html5_adjust_effective_request_size=true&html5_hopeless_mode_request_size_secs=40&mpu_visible_threshold_count=2&vss_dni_delayping=0&disable_new_pause_state3=true&html5_disable_non_contiguous=true&flex_theater_mode=true&lugash_header_warmup=true&html5_min_readbehind_cap_secs=0&youtubei_for_web=true&disable_reporting_html5_no_vast_ads_as_error=true&html5_vp9_live_whitelist=false&html5_suspended_state=true&html5_connect_timeout_secs=7.0&web_player_flash_fallback_killswitch=true&use_push_for_desktop_live_chat=true&html5_min_secs_between_format_selections=8.0&gapi_hint_params=m;/_/scs/abc-static/_/js/k=gapi.gapi.en.BznCEch7yrY.O/m=__features__/rt=j/d=1/rs=AHpOoo89FbxkNsIBOnpzYJliP4nzTuPXPg&view_count=138746&gut_tag=/4061/ytunknown/main&core_dbp=ChZoWFduSWZZN2VpcG9CaWVYWnBPSndBEAEgASgA&midroll_freqcap=600.0&apply_fade_on_midrolls=True&ad3_module=1&iv_allow_in_place_switch=1&adaptive_fmts=init=0-715&itag=137&fps=25&xtags=&url=https://r1---sn-4g5e6nls.googlevideo.com/videoplayback?ei=om5qWfj6NYL_WNjYpIAD&key=yt6&keepalive=yes&initcwndbps=556250&expire=1500168963&clen=142261087&source=youtube&signature=A81AFBC28F4D37951D2A3CA9F9370EBC07E410E4.BD5547C59956D93C2B351B302DFD86E85451A0CA&lmt=1497979028342198&ipbits=0&mv=m&gir=yes&mt=1500147287&pl=21&itag=137&ms=au&requiressl=yes&mime=video/mp4&id=o-AIlu0RkrqMnKv9EvUKiHDF8r6kAlczSgWVujKgm6Rz4V&dur=458.520&mm=31&ip=95.14.68.108&mn=sn-4g5e6nls&sparams=clen,dur,ei,gir,id,initcwndbps,ip,ipbits,itag,keepalive,lmt,mime,mm,mn,ms,mv,pl,requiressl,source,expire&bitrate=3799443&type=video/mp4;+codecs="avc1.640028"&lmt=1497979028342198&projection_type=1&quality_label=1080p&index=716-1827&size=1920x1080&clen=142261087,init=0-242&itag=248&fps=25&xtags=&url=https://r1---sn-4g5e6nls.googlevideo.com/videoplayback?ei=om5qWfj6NYL_WNjYpIAD&key=yt6&keepalive=yes&initcwndbps=556250&expire=1500168963&clen=158398468&source=youtube&signature=CCC0D2490353B0065E5829F151305D95AEDE55B9.7CF4D0EE40ACB221728D8AFDF084E6A5DFABCD98&lmt=1497816474083876&ipbits=0&mv=m&gir=yes&mt=1500147287&pl=21&itag=248&ms=au&requiressl=yes&mime=video/webm&id=o-AIlu0RkrqMnKv9EvUKiHDF8r6kAlczSgWVujKgm6Rz4V&dur=458.480&mm=31&ip=95.14.68.108&mn=sn-4g5e6nls&sparams=clen,dur,ei,gir,id,initcwndbps,ip,ipbits,itag,keepalive,lmt,mime,mm,mn,ms,mv,pl,requiressl,source,expire&bitrate=3123739&type=video/webm;+codecs="vp9"&lmt=1497816474083876&projection_type=1&quality_label=1080p&index=243-1842&size=1920x1080&clen=158398468,init=0-713&itag=136&fps=25&xtags=&url=https://r1---sn-4g5e6nls.googlevideo.com/videoplayback?ei=om5qWfj6NYL_WNjYpIAD&key=yt6&keepalive=yes&initcwndbps=556250&expire=1500168963&clen=79105869&source=youtube&signature=CDB118EDE7B63DDC9550F367E9F07830799655ED.D3EF922360819B481CF6ECC2763559AB0C3478AF&lmt=1497979016153211&ipbits=0&mv=m&gir=yes&mt=1500147287&pl=21&itag=136&ms=au&requiressl=yes&mime=video/mp4&id=o-AIlu0RkrqMnKv9EvUKiHDF8r6kAlczSgWVujKgm6Rz4V&dur=458.520&mm=31&ip=95.14.68.108&mn=sn-4g5e6nls&sparams=clen,dur,ei,gir,id,initcwndbps,ip,ipbits,itag,keepalive,lmt,mime,mm,mn,ms,mv,pl,requiressl,source,expire&bitrate=2332623&type=video/mp4;+codecs="avc1.4d401f"&lmt=1497979016153211&projection_type=1&quality_label=720p&index=714-1825&size=1280x720&clen=79105869,init=0-242&itag=247&fps=25&xtags=&url=https://r1---sn-4g5e6nls.googlevideo.com/videoplayback?ei=om5qWfj6NYL_WNjYpIAD&key=yt6&keepalive=yes&initcwndbps=556250&expire=1500168963&clen=86507558&source=youtube&signature=93A41C597A00D1FA8E3D96781BF75C7DE64D9B1B.4DFE8C0F918A97505996A2CC7549D48D260BEBF5&lmt=1497816799001841&ipbits=0&mv=m&gir=yes&mt=1500147287&pl=21&itag=247&ms=au&requiressl=yes&mime=video/webm&id=o-AIlu0RkrqMnKv9EvUKiHDF8r6kAlczSgWVujKgm6Rz4V&dur=458.480&mm=31&ip=95.14.68.108&mn=sn-4g5e6nls&sparams=clen,dur,ei,gir,id,initcwndbps,ip,ipbits,itag,keepalive,lmt,mime,mm,mn,ms,mv,pl,requiressl,source,expire&bitrate=1767900&type=video/webm;+codecs="vp9"&lmt=1497816799001841&projection_type=1&quality_label=720p&index=243-1834&size=1280x720&clen=86507558,init=0-714&itag=135&fps=25&xtags=&url=https://r1---sn-4g5e6nls.googlevideo.com/videoplayback?ei=om5qWfj6NYL_WNjYpIAD&key=yt6&keepalive=yes&initcwndbps=556250&expire=1500168963&clen=44918449&source=youtube&signature=1B71C220D58B22A6971AADFB121760093B6B2C16.6FFD92B792E9A31D2F69B194D3ED2D0548E7F245&lmt=1497979015179453&ipbits=0&mv=m&gir=yes&mt=1500147287&pl=21&itag=135&ms=au&requiressl=yes&mime=video/mp4&id=o-AIlu0RkrqMnKv9EvUKiHDF8r6kAlczSgWVujKgm6Rz4V&dur=458.520&mm=31&ip=95.14.68.108&mn=sn-4g5e6nls&sparams=clen,dur,ei,gir,id,initcwndbps,ip,ipbits,itag,keepalive,lmt,mime,mm,mn,ms,mv,pl,requiressl,source,expire&bitrate=1168568&type=video/mp4;+codecs="avc1.4d401e"&lmt=1497979015179453&projection_type=1&quality_label=480p&index=715-1826&size=854x480&clen=44918449,init=0-242&itag=244&fps=25&xtags=&url=https://r1---sn-4g5e6nls.googlevideo.com/videoplayback?ei=om5qWfj6NYL_WNjYpIAD&key=yt6&keepalive=yes&initcwndbps=556250&expire=1500168963&clen=42553772&source=youtube&signature=946B26FD19005B4A77678CF58359B091AA196647.AF6B0B71C672F97F34B50DDFCE58B184A86DD311&lmt=1497816797643690&ipbits=0&mv=m&gir=yes&mt=1500147287&pl=21&itag=244&ms=au&requiressl=yes&mime=video/webm&id=o-AIlu0RkrqMnKv9EvUKiHDF8r6kAlczSgWVujKgm6Rz4V&dur=458.480&mm=31&ip=95.14.68.108&mn=sn-4g5e6nls&sparams=clen,dur,ei,gir,id,initcwndbps,ip,ipbits,itag,keepalive,lmt,mime,mm,mn,ms,mv,pl,requiressl,source,expire&bitrate=891875&type=video/webm;+codecs="vp9"&lmt=1497816797643690&projection_type=1&quality_label=480p&index=243-1816&size=854x480&clen=42553772,init=0-714&itag=134&fps=25&xtags=&url=https://r1---sn-4g5e6nls.googlevideo.com/videoplayback?ei=om5qWfj6NYL_WNjYpIAD&key=yt6&keepalive=yes&initcwndbps=556250&expire=1500168963&clen=23508086&source=youtube&signature=1C0ECE53DF3F8D44509FB39E4E482A810BCC080E.916A6FF5E8B24D9B7A650A180C4984C15AB78E5B&lmt=1497979014659412&ipbits=0&mv=m&gir=yes&mt=1500147287&pl=21&itag=134&ms=au&requiressl=yes&mime=video/mp4&id=o-AIlu0RkrqMnKv9EvUKiHDF8r6kAlczSgWVujKgm6Rz4V&dur=458.520&mm=31&ip=95.14.68.108&mn=sn-4g5e6nls&sparams=clen,dur,ei,gir,id,initcwndbps,ip,ipbits,itag,keepalive,lmt,mime,mm,mn,ms,mv,pl,requiressl,source,expire&bitrate=633970&type=video/mp4;+codecs="avc1.4d401e"&lmt=1497979014659412&projection_type=1&quality_label=360p&index=715-1826&size=640x360&clen=23508086,init=0-242&itag=243&fps=25&xtags=&url=https://r1---sn-4g5e6nls.googlevideo.com/videoplayback?ei=om5qWfj6NYL_WNjYpIAD&key=yt6&keepalive=yes&initcwndbps=556250&expire=1500168963&clen=23535825&source=youtube&signature=64D565D1DF5DE6B15DC5EE2EE615B2B69A27FD54.AA0F53B5E818B5653291E9755A2712E501028609&lmt=1497816797800637&ipbits=0&mv=m&gir=yes&mt=1500147287&pl=21&itag=243&ms=au&requiressl=yes&mime=video/webm&id=o-AIlu0RkrqMnKv9EvUKiHDF8r6kAlczSgWVujKgm6Rz4V&dur=458.480&mm=31&ip=95.14.68.108&mn=sn-4g5e6nls&sparams=clen,dur,ei,gir,id,initcwndbps,ip,ipbits,itag,keepalive,lmt,mime,mm,mn,ms,mv,pl,requiressl,source,expire&bitrate=478817&type=video/webm;+codecs="vp9"&lmt=1497816797800637&projection_type=1&quality_label=360p&index=243-1788&size=640x360&clen=23535825,init=0-713&itag=133&fps=25&xtags=&url=https://r1---sn-4g5e6nls.googlevideo.com/videoplayback?ei=om5qWfj6NYL_WNjYpIAD&key=yt6&keepalive=yes&initcwndbps=556250&expire=1500168963&clen=13962368&source=youtube&signature=6CAFDFFD0FB4A1CCFDA3C54B7473FF2569EFE8AC.AEA43F8A56C9028D31932DBE1F7AF042E40099A7&lmt=1497979014440001&ipbits=0&mv=m&gir=yes&mt=1500147287&pl=21&itag=133&ms=au&requiressl=yes&mime=video/mp4&id=o-AIlu0RkrqMnKv9EvUKiHDF8r6kAlczSgWVujKgm6Rz4V&dur=458.520&mm=31&ip=95.14.68.108&mn=sn-4g5e6nls&sparams=clen,dur,ei,gir,id,initcwndbps,ip,ipbits,itag,keepalive,lmt,mime,mm,mn,ms,mv,pl,requiressl,source,expire&bitrate=286948&type=video/mp4;+codecs="avc1.4d4015"&lmt=1497979014440001&projection_type=1&quality_label=240p&index=714-1825&size=426x240&clen=13962368,init=0-241&itag=242&fps=25&xtags=&url=https://r1---sn-4g5e6nls.googlevideo.com/videoplayback?ei=om5qWfj6NYL_WNjYpIAD&key=yt6&keepalive=yes&initcwndbps=556250&expire=1500168963&clen=12769212&source=youtube&signature=A49774FB936FBACCFF7993E6644AB6D35B87F6
You see its not full data I need from get_video_info.Its just a part of it.How can i solve this?
Use HttpClient it is much simpler than HttpWebRequest
using (var client = new HttpClient()) {
var response = await client.GetAsync(url);
string content = await response.Content.ReadAsStringAsync();
}
HttpClient is the best of both worlds (i.e. WebClient and HttpWebRequest)

Some error when get data from HTTP request with post

I follow the instruction at: HTTP request with post to get the audio file from site: http://www.tudienabc.com/phat-am-tieng-nhat (This site allow us to input the english or japanese word/phrase/ sentence and generate the audio file, look like "/pronunciations/audio?file_name=1431134309.002.mp3&file_type=mp3" at line 129 of HTML code after postback).
However, the audio file which i get from my own application is not same with the one generated from this website. The audio file (mp3) generated from this website can play at www.tudienabc.com/pronunciations/ (such as: www.tudienabc.com/pronunciations/audio?file_name=1431141268.9947.mp3&file_type=mp3), but the audio file generated from my application can not play (such as: www.tudienabc.com/pronunciations/audio?file_name=1431141475.4908.mp3&file_type=mp3).
So, what wrong? And how to get the exact audio file?
Here is my code:
var request = (HttpWebRequest)WebRequest.Create("http://www.tudienabc.com/phat-am-tieng-nhat");
var postData = "_method=POST&data[Pronun][text]=hello&data[Pronun][type]=3";
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();
int m = responseString.IndexOf("pronunciations/audio?file_name=")+"pronunciations/audio?file_name=".Length;
int n = responseString.IndexOf("&file_type=mp3");
string filename = responseString.Substring(m, n - m);
return filename;
Thank you,
Their website processes the audio using ECMAScript
<script>
var wait = new waitGenerateAudio(
'#progress_audio_placeholder',
'/pronunciations/checkFinish/1431151184.739',
'aGVsbG8gZnlyeWU=',
'/pronunciations/audio?file_name=1431151184.739.mp3&file_type=mp3',
'T?o file l?i'
);
</script>
You will need to be able to process the JavaScript for the audio file to be created.
Checkout
C# httpwebrequest and javascript
or
WebClient runs javascript
For utilizing a headless browser.
I suggest looking into a more versatile library for text to audio.
https://gist.github.com/alotaiba/1728771

how to read content from webpage

I want to access a webpage & store the contents of the webpage into a database
this is the code I have tried for reading the contents of the webpage
public static WebClient wClient = new WebClient();
public static TextWriter textWriter;
public static String readFromLink()
{
string url = "http://www.ncedc.org/cgi-bin/catalog-search2.pl";
HttpWebRequest webRequest = WebRequest.Create(url) as HttpWebRequest;
webRequest.Method = "POST";
System.Net.WebClient client = new System.Net.WebClient();
byte[] data = client.DownloadData(url);
string html = System.Text.Encoding.UTF8.GetString(data);
return html;
}
public static bool WriteTextFile(String fileName, String t)
{
try
{
textWriter = new StreamWriter(fileName);
}
catch (Exception)
{
return false;
Console.WriteLine("Data Save Unsuccessful: Could Not create File");
}
try
{
textWriter.WriteLine(t);
}
catch (Exception)
{
return false;
Console.WriteLine("Data Save UnSuccessful: Could Not Save Data");
}
textWriter.Close();
return true;
Console.WriteLine("Data Save Successful");
}
static void Main(string[] args)
{
String saveFile = "E:/test.txt";
String reSultString = readFromLink();
WriteTextFile(saveFile, reSultString);
Console.ReadKey();
}
but this code gives me an o/p as- This script should be referenced with a METHOD of POST. REQUEST_METHOD=GET
please tell me how to resolve this
You are mixing HttpWebRequest with System.Net.WebClient code. They are a different. You can use WebClient.UploadValues to send a POST with WebClient. You will also need to provide some POST data:
System.Net.WebClient client = new System.Net.WebClient();
NameValueCollection postData = new NameValueCollection();
postData.Add("format","ncread");
postData.Add("mintime","2002/01/01,00:00:00");
postData.Add("minmag","3.0");
postData.Add("etype","E");
postData.Add("outputloc","web");
postData.Add("searchlimit","100000");
byte[] data = client.UploadValues(url, "POST", postData);
string html = System.Text.Encoding.UTF8.GetString(data);
You can find out what parameters to pass by inspecting the POST message in Fiddler. And yes, as commented by #Chris Pitman, use File.WriteAllText(path, html);
I'm not sure if it's a fault on your side as I get the same message just by opening the page. The page source does not contain any html so I don't think you can do webRequest.Method = "POST". Have you spoken to the administrators of the site?
The .NET framework provides a rich set of methods to access data stored on the web. First you will have to include the right namespaces:
using System.Text;
using System.Net;
using System.IO;
The HttpWebRequest object allows us to create a request to the URL, and the WebResponse allows us to read the response to the request.
We’ll use a StreamReader object to read the response into a string variable.
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(URL);
myRequest.Method = "GET";
WebResponse myResponse = myRequest.GetResponse();
StreamReader sr = new StreamReader(myResponse.GetResponseStream(), System.Text.Encoding.UTF8);
string result = sr.ReadToEnd();
sr.Close();
myResponse.Close();
In this code sample, the URL variable should contain the URL that you want to get, and the result variable will contain the contents of the web page. You may want to add some error handling as well for a real application.
As far as I see, the URL you're requesting is a perl script. I think it demands POST to get search arguments and therefore delivers search results.

Download files from Google Books

I'm writing very simple application. It is supposed to download files from internet. I have URLs and names for files to save in tables. But my code doesn't work.
for (int i = 1; i < links.Length; i++)
{
Uri uri = new Uri(links[i]);
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(uri);
webRequest.Method = "GET";
HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse();
Stream responseStream = webResponse.GetResponseStream();
StreamReader responseStreamReader = new StreamReader(responseStream);
String result = responseStreamReader.ReadToEnd();
StreamWriter w = new StreamWriter(savepath + names[i]);
w.Write(result);
w.Close();
break;
}
example url:
http://books.google.pl/books?id=yOz1ePt39WQC&pg=PA2&img=1&zoom=3&hl=pl&sig=ACfU3U0MDQtXGU_3YVqGvcsDiWLLcKh0KA&w=800&gbd=1
example name:
002.png
Files are to be saved as PNG image but instead I get something that begins with
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
Second qestion. How can I detect HTTP 404 error when trying to download?
EDIT:
My bad. my links were incorrect. After replacing & with & they are correct.
Example link (correctted):
http://books.google.pl/books?id=yOz1ePt39WQC&pg=PA2&img=1&zoom=3&hl=pl&sig=ACfU3U0MDQtXGU_3YVqGvcsDiWLLcKh0KA&w=800&gbd=1
Despite of that I can't still download PNGs correctly.
They are not opening. But at least they are not HTML pages.
I'm thinking that trying to save them as a string is not good idea. But I don't know how else I could do that. Maybe using byte[] or something?
Have you tried WebClient.DownloadFile ?
string url = "http://books.google.pl/books?id=yOz1ePt39WQC&pg=PA2&img=1&zoom=3&hl=pl&sig=ACfU3U0MDQtXGU_3YVqGvcsDiWLLcKh0KA&w=800&gbd=1";
string file = "002.png";
WebClient wc = new WebClient();
wc.DownloadFile(url, file);
will save the image in the application directory as 002.png.

Categories