Dear all,
I am trying to make a code to get HTML source from "http://vnexpress.net" (a news site in my country). I am using file_get_contents as below:
<?
$homepage = file_get_contents('http://vnexpress.net');
echo $homepage;
?>
I also tried to use CURL and set request header information to be similar with chrome browser but not effect. My php always return a garbage code like below:
‹Ã½`I–%&/mÊ{JõJ×à t¡€`$ØÂ@ìÈÃæ’ìiG#)«*ÂÊeVe]f@Ìü÷Þ{ï½÷Þ{ï½÷º;ÂN'÷ßÿ?\fdl öÎJÚÉž!€ªÈ?~|?"ÿ®O¿|(>J¹ýÂ=žçà ™Å’~ý±{¼ÈÛŒpnWÛù/Z—Ÿ}tR-Û|Ùn¿¹^å¥Sùë³ÂÚü]{0Óé<«›¼ýì«7ö>JïýØÂ9PËl‘ö Q]Mª¶ñ^?{ñôô÷=ûòùó/¿‹Wi¯ù,o¦u±Â¸¼wÞÌÿÑ¿my‘¶Å2]γå<ý…ÙbuËœ.þã¿÷Ã-è“ÿøïùËÛôû“ÿ‰¿é?þ{ÿÒi:ýÂÿ ž¿~ÅŸþõm:ÿGÿ"zñ¢øÂÿÞ?œ¾¡÷Ûÿø ïý«§éOÃ’d›¾È ª¥æÿ ·#ˆ—ÿñßû§ïþÑ¿4ÂÿÇïŸ]ŒÒ·u9«¨ãQºšÿ£ñ*-×€NßÌ+¢Ùü÷þñÓQ:e—ôç9Jà ¿Âÿž¿wDÈ>ü“—£ôòûC—„Úßš Ò:«¨¿¿çï$`Ã?ú—,ÃäoÂÇJ™¶hËüxà ‹Â¸ryúnUçM“n§ÿØŸ„~ÓÉ?úWô.5‘¡UË ²XæéÞþüñ]yÂ':Ëœâ€Â·Ã¹ÃµUUÃüi±ÂG?Yä-5K_äWMú4+摄)5«×£/öèŒÞ©—y;ú"»È~€O>ÃÚü*»={ùfô²ª Û¬Y¤Gþ„Œ€.‘ƒýG2Æýè¿·2Cþf4€Âh±ÎðåräHÕþ~ûË—òò4-ÿÑ¿h1úö?ú¥/xÆ^ÿ£Q‘~þÂþ-KH½üÕÓÑ·iÊþÃÑ?ö'q£¿ço§iøɧ'£< ÖÑ문¨–Òë‹‹Õè'Oߌ^ÌÿÑ¿d™à ŽÃ¨Å¸Ã‘sê3øgÓK¿x¡(þM¸Âk†‘f4NzgVäÔûš‡B£~}A#z’-G¯¨ÃORÛ7kú±D³iúœ°ùv¶¬ ú7}A?5üHñ“`È)~âÇ·×ùè)5̵§Ù?^" 3‡Ÿ)~!ôg}A? _ú˜·9ÿHõ§Œ¿Qúüçɲ¯^Â>{uúúÛ ïìììà …>£µÃï?%Ö¸¨êëß¿˜ù¯°Jõé¼’Õm 1-óþ©ö@\ø6*óò³ÂšöºÌ›yž·¥ó:?ÿì £»¯ò¦Z×ÓüîIµXTË»³ü<[—ÃxÚ¿·¤Ë¨¨0þ›Fùc?–ŠÚÂÿ=ÃY .'ìÃ[ÙjU4Ã’Mwë¦ù„Ô,}óćóÕëיׯ ï~þü.´õÅöt¾Ó‹è}q‡øÿcÑyÚ #÷ÓÙe&Ÿ~â€â€“ôî:» ¯üO›zJðŸ“:«¯ÃXõýñO7=¾+miˆ©à ¥Â³Ã¡Â¾nÃ×O.óF7Ãʬ™‘ʬ۞ŸÂÂ:{÷Š˜=oÚ°Ëov®.I|µ,¾Ñ.,ïïìÜ=®ë/òå:„O„â‡HG´{þ^˧ŒäÂ]fuúòøóÓßÿõÙ›ÓÃvÃɾ?=}õÙî!։ >?{|öôË/N_¿9;ùýÃ^ÚÃÉ¡ £X^|QÃò*Ã;™ü´á?ä÷Û!o>ÃJ'£O)t@à ¿ÃŸÃœÂ·Ã‚@~ÿ‹ì¥ŸÉŸù™ô{ßg¬ñçxµ næ[ßûø÷§qO§ÕzÙ~^ÕU[M«2ý=Rmx÷nÓâ€Â§Âäoú“çÂ蘭¤Â/ªê¢Ì·É¾–×dššñ´ZÜ¥ž~ºù˜;Å€à ªÃ“vs‘·:˜æÉõ›ì‚ÃÃœ ë{;ß?Lݖ*«©Ãâòq±lòº}’ŸWu¾uAna#äû%w¶øŸ+é–+i ¨Ã„ÌÅòÓ¤ºêëÃÃñ§ã{ãE±$4=¾–9!ßRà ¾`ì¸ðP÷¿q‚Ãbš¿]µ4d>³Ãù/ùc´ ]*Ã’DJ }¹ÌwÙuˆ, ÑhÂQöýžmùF‚ÌtIfYÃo‡2¯ów×Ç%(]½»ÛÃþ˜TïØ9€/ÀÃIç>ü>ú·†|¹;&sÃŒSÃ’M« ¿OªÙ5¨'(ȿ‹åjmð˜³YNAQ1£Èl]Æ’užÔÕñÃw‹YKÛeV®©Âñ._~=¯®žÂ¨^à ”$Üäaé{ä_ñ‹?öxV\rCúùº,f9éJòŸžçç< èÿÙGûþv¯Hv-+ýÃÃûnUIˆú¨..æ„Kµ:¬.ózû¼¬® N‡ÓuÃTõ£UEm^‚ÜÛYY\èK‡«l6#cðhgõî ÃÂKËwùìw-+Kje¿É&MU®Ûü0½û*"ÿ4%gËœ>£n¿u÷°¤1&]’`éÂŒþO €ôÃ8-·Iþt²ñ˜Ü¤i€f=Y$¬uÞ®ëez2çoÖlË:b ¯ùÕ1¹S$ØLYÃ’=âÞ Ô1ɱDîcJÿÜ]RÆIÃ$ý‘f%ô/éŸ8‡ð7Ø—LV¶DÅ¡6óM0øËÛ7ÿñßûà —RrÂ2€â€ÃµÃ»Ã«â€a¤ŒÒâ#“j/éïËå3ü¹GÚ*ZRânV]ÑôÂõŠ4Ú²@ÀDâd›A:Oè/óFFâ€AÑ/:†ö]+äHÃiN ö¤5«åâ€rooOcQžÄ“ÄÊ‘žnÕî²Î1ó éã)r²N–^Ÿ~úìéÃéɃÃgÇ>ÃÞ?~p² }ðìôÞöÓ'Ÿîܲòðäâ€â€Å¾Å’êâ6¯s ¼Â´Å¸Â¬Ã›Ã—úÊã»à ,þÃ2¦ûåwÃÞþ^qžRZ(=;M?ý>xô$þ>;ýÔ؆º'&`uÄ:Ùèèþ‹xÆ’5ôŽQ¹Ä8¤ÑÉ2S2;«/ ²èô«¾Ä¿‹OI…ø¦ó|ö(ûO¡§šþ ?;zü»~/_Ίóïoo3ª„²¡5MÉ1}øcÂ×%ÿ„?}ä7!&¡#\à ƒPñcòÃÂ¥9ÿCï˜æÂ#²þò%l±†–hÃ¥b…žŸÓ‡"ýï¾Hù´µ¢>÷ â„¢ úDà ÌçsÅ¡D4•/†À¾B|JT‘»Â{@3FŸÃ·¤wèŸhøM½ÉåI¤Q Ë#¿] `Ã…LªS¾åÀ)-Ã/-•|ôû³8nQ]â€â€œÃ¹Ã›QEVZX‘’קÜ죣Süà ÂÓXäuqÿ§‘Ùy»]×*S?‹›;ÿéj
My code is perfect with other site but always fail with "vnexpress.net". Hope you give me some advises. Thank you so much.
I am trying to make a code to get HTML source from "http://vnexpress.net" (a news site in my country). I am using file_get_contents as below:
<?
$homepage = file_get_contents('http://vnexpress.net');
echo $homepage;
?>
I also tried to use CURL and set request header information to be similar with chrome browser but not effect. My php always return a garbage code like below:
‹Ã½`I–%&/mÊ{JõJ×à t¡€`$ØÂ@ìÈÃæ’ìiG#)«*ÂÊeVe]f@Ìü÷Þ{ï½÷Þ{ï½÷º;ÂN'÷ßÿ?\fdl öÎJÚÉž!€ªÈ?~|?"ÿ®O¿|(>J¹ýÂ=žçà ™Å’~ý±{¼ÈÛŒpnWÛù/Z—Ÿ}tR-Û|Ùn¿¹^å¥Sùë³ÂÚü]{0Óé<«›¼ýì«7ö>JïýØÂ9PËl‘ö Q]Mª¶ñ^?{ñôô÷=ûòùó/¿‹Wi¯ù,o¦u±Â¸¼wÞÌÿÑ¿my‘¶Å2]γå<ý…ÙbuËœ.þã¿÷Ã-è“ÿøïùËÛôû“ÿ‰¿é?þ{ÿÒi:ýÂÿ ž¿~ÅŸþõm:ÿGÿ"zñ¢øÂÿÞ?œ¾¡÷Ûÿø ïý«§éOÃ’d›¾È ª¥æÿ ·#ˆ—ÿñßû§ïþÑ¿4ÂÿÇïŸ]ŒÒ·u9«¨ãQºšÿ£ñ*-×€NßÌ+¢Ùü÷þñÓQ:e—ôç9Jà ¿Âÿž¿wDÈ>ü“—£ôòûC—„Úßš Ò:«¨¿¿çï$`Ã?ú—,ÃäoÂÇJ™¶hËüxà ‹Â¸ryúnUçM“n§ÿØŸ„~ÓÉ?úWô.5‘¡UË ²XæéÞþüñ]yÂ':Ëœâ€Â·Ã¹ÃµUUÃüi±ÂG?Yä-5K_äWMú4+摄)5«×£/öèŒÞ©—y;ú"»È~€O>ÃÚü*»={ùfô²ª Û¬Y¤Gþ„Œ€.‘ƒýG2Æýè¿·2Cþf4€Âh±ÎðåräHÕþ~ûË—òò4-ÿÑ¿h1úö?ú¥/xÆ^ÿ£Q‘~þÂþ-KH½üÕÓÑ·iÊþÃÑ?ö'q£¿ço§iøɧ'£< ÖÑ문¨–Òë‹‹Õè'Oߌ^ÌÿÑ¿d™à ŽÃ¨Å¸Ã‘sê3øgÓK¿x¡(þM¸Âk†‘f4NzgVäÔûš‡B£~}A#z’-G¯¨ÃORÛ7kú±D³iúœ°ùv¶¬ ú7}A?5üHñ“`È)~âÇ·×ùè)5̵§Ù?^" 3‡Ÿ)~!ôg}A? _ú˜·9ÿHõ§Œ¿Qúüçɲ¯^Â>{uúúÛ ïìììà …>£µÃï?%Ö¸¨êëß¿˜ù¯°Jõé¼’Õm 1-óþ©ö@\ø6*óò³ÂšöºÌ›yž·¥ó:?ÿì £»¯ò¦Z×ÓüîIµXTË»³ü<[—ÃxÚ¿·¤Ë¨¨0þ›Fùc?–ŠÚÂÿ=ÃY .'ìÃ[ÙjU4Ã’Mwë¦ù„Ô,}óćóÕëיׯ ï~þü.´õÅöt¾Ó‹è}q‡øÿcÑyÚ #÷ÓÙe&Ÿ~â€â€“ôî:» ¯üO›zJðŸ“:«¯ÃXõýñO7=¾+miˆ©à ¥Â³Ã¡Â¾nÃ×O.óF7Ãʬ™‘ʬ۞ŸÂÂ:{÷Š˜=oÚ°Ëov®.I|µ,¾Ñ.,ïïìÜ=®ë/òå:„O„â‡HG´{þ^˧ŒäÂ]fuúòøóÓßÿõÙ›ÓÃvÃɾ?=}õÙî!։ >?{|öôË/N_¿9;ùýÃ^ÚÃÉ¡ £X^|QÃò*Ã;™ü´á?ä÷Û!o>ÃJ'£O)t@à ¿ÃŸÃœÂ·Ã‚@~ÿ‹ì¥ŸÉŸù™ô{ßg¬ñçxµ næ[ßûø÷§qO§ÕzÙ~^ÕU[M«2ý=Rmx÷nÓâ€Â§Âäoú“çÂ蘭¤Â/ªê¢Ì·É¾–×dššñ´ZÜ¥ž~ºù˜;Å€à ªÃ“vs‘·:˜æÉõ›ì‚ÃÃœ ë{;ß?Lݖ*«©Ãâòq±lòº}’ŸWu¾uAna#äû%w¶øŸ+é–+i ¨Ã„ÌÅòÓ¤ºêëÃÃñ§ã{ãE±$4=¾–9!ßRà ¾`ì¸ðP÷¿q‚Ãbš¿]µ4d>³Ãù/ùc´ ]*Ã’DJ }¹ÌwÙuˆ, ÑhÂQöýžmùF‚ÌtIfYÃo‡2¯ów×Ç%(]½»ÛÃþ˜TïØ9€/ÀÃIç>ü>ú·†|¹;&sÃŒSÃ’M« ¿OªÙ5¨'(ȿ‹åjmð˜³YNAQ1£Èl]Æ’užÔÕñÃw‹YKÛeV®©Âñ._~=¯®žÂ¨^à ”$Üäaé{ä_ñ‹?öxV\rCúùº,f9éJòŸžçç< èÿÙGûþv¯Hv-+ýÃÃûnUIˆú¨..æ„Kµ:¬.ózû¼¬® N‡ÓuÃTõ£UEm^‚ÜÛYY\èK‡«l6#cðhgõî ÃÂKËwùìw-+Kje¿É&MU®Ûü0½û*"ÿ4%gËœ>£n¿u÷°¤1&]’`éÂŒþO €ôÃ8-·Iþt²ñ˜Ü¤i€f=Y$¬uÞ®ëez2çoÖlË:b ¯ùÕ1¹S$ØLYÃ’=âÞ Ô1ɱDîcJÿÜ]RÆIÃ$ý‘f%ô/éŸ8‡ð7Ø—LV¶DÅ¡6óM0øËÛ7ÿñßûà —RrÂ2€â€ÃµÃ»Ã«â€a¤ŒÒâ#“j/éïËå3ü¹GÚ*ZRânV]ÑôÂõŠ4Ú²@ÀDâd›A:Oè/óFFâ€AÑ/:†ö]+äHÃiN ö¤5«åâ€rooOcQžÄ“ÄÊ‘žnÕî²Î1ó éã)r²N–^Ÿ~úìéÃéɃÃgÇ>ÃÞ?~p² }ðìôÞöÓ'Ÿîܲòðäâ€â€Å¾Å’êâ6¯s ¼Â´Å¸Â¬Ã›Ã—úÊã»à ,þÃ2¦ûåwÃÞþ^qžRZ(=;M?ý>xô$þ>;ýÔ؆º'&`uÄ:Ùèèþ‹xÆ’5ôŽQ¹Ä8¤ÑÉ2S2;«/ ²èô«¾Ä¿‹OI…ø¦ó|ö(ûO¡§šþ ?;zü»~/_Ίóïoo3ª„²¡5MÉ1}øcÂ×%ÿ„?}ä7!&¡#\à ƒPñcòÃÂ¥9ÿCï˜æÂ#²þò%l±†–hÃ¥b…žŸÓ‡"ýï¾Hù´µ¢>÷ â„¢ úDà ÌçsÅ¡D4•/†À¾B|JT‘»Â{@3FŸÃ·¤wèŸhøM½ÉåI¤Q Ë#¿] `Ã…LªS¾åÀ)-Ã/-•|ôû³8nQ]â€â€œÃ¹Ã›QEVZX‘’קÜ죣Süà ÂÓXäuqÿ§‘Ùy»]×*S?‹›;ÿéj
My code is perfect with other site but always fail with "vnexpress.net". Hope you give me some advises. Thank you so much.
Comment