2

My question is that how can we save some html page for given url.. like if I will put the url "http://www.google.com/" then how we will save this page as html on server via php... the purpose is to read that page with utf-8 charset.. the current charset is windows-1255.. and I want to change the chrset to utf-8 or if there is any option to read that page with current charset when there is some other language in that page...

Actually I wana read the contents after search done.. of this page "http://elyon1.court.gov.il/verdictssearch/HebrewVerdictsSearch.aspx"

If there is any solution....

I m using PHP for serverside language..

stratosgear
  • 942
  • 1
  • 16
  • 37
Fred Tanrikut
  • 9,951
  • 4
  • 17
  • 7

2 Answers2

3

You can save the contents with file_get_contents:

$page = file_get_contents('http://elyon1.court.gov.il/verdictssearch/HebrewVerdictsSearch.aspx');

And then convert the charset with iconv:

$converted_page = iconv('windows-1252','utf-8',$page);
Bryan Agee
  • 4,924
  • 3
  • 26
  • 42
0
// this is 'windows-1251' encoded page
$remote_page = 'http://www.gramota.ru/'; 

$doc = file_get_contents($remote_page);

// to get 'UTF-8' encoded content
$docutf8 = mb_convert_encoding($doc, 'UTF-8', 'windows-1251'); 

to show original document in original encoding (windows-1251)...

  header('Content-Type: text/html; charset=windows-1251');
  echo $doc;

to show original document in UTF-8 encoding (converted from windows-1251)...

  header('Content-Type: text/html; charset=utf-8');
  echo $docutf8;
Wh1T3h4Ck5
  • 8,399
  • 9
  • 59
  • 79
  • I wanna submit 2 parameters to this page with post method before reading the page contents... – Fred Tanrikut Apr 13 '11 at 08:12
  • Edit your question please. I can't see that in title or question description. Question was about getting remote content and changing encoding charset. – Wh1T3h4Ck5 Apr 13 '11 at 08:21
  • I did mention there this thing but was not much clear it is "Actually I wana read the contents after search done.. of this page 'http://elyon1.court.gov.il/verdictssearch/HebrewVerdictsSearch.aspx'" – Fred Tanrikut Apr 13 '11 at 09:47
  • http://stackoverflow.com/questions/5647461/i-want-to-read-the-contents-via-php-after-search-query-done – Fred Tanrikut Apr 13 '11 at 10:06