Færdiggjort

Problems with encode of files PHP

To reproduce the problem, I attached 2 files:

======

My objetive is extract data of the file [login to view URL] with xpath of PHP

======

- [login to view URL] (no touch, no edit, it is IMPORTANT)

- [login to view URL] (you can work here)

<?php

$html =file_get_contents("[login to view URL]");

$dom = new \DOMDocument();

@$dom->loadHTML((string) $html);

$xpath = new \DOMXPath($dom);

$title = $xpath->query('//h3[@class="tb-main-title"]');

if(count($title)>0){

print_r($title[0]->nodeValue); // out 小米 红米S2蝴蝶花镜子皮套手机壳 红米Y2插卡全包防摔保护套男女

}

If u execute the last code all is okay....

=========

- BUT if you switch to file_get_contents("[login to view URL]") it not work.

- why, (if the content is same)?

- Ok, a clue.

- remove your file [login to view URL] of ur computer and copy [login to view URL] (linux/mac: cp [login to view URL] [login to view URL])

- now u have a again your file [login to view URL] switch to file_get_contents("[login to view URL]")

- not work right?

- with ur code editor (phpStorm, Netbeans, etc) add or remove any thing. Example, you go to the line #1 and give an Enter (new line empty)

- Now all work okay again

- Why? well, this is the problem...

- I think is any related with file encode, I think when we edit the file [login to view URL] with a code editor (ex. phpStorm) this editor add a special encode (and correct).

check:

==========

[root@65be04194cde wse-back]# file src/Demiurgo/Taobao/Items/Crawler/[login to view URL]

src/Demiurgo/Taobao/Items/Crawler/[login to view URL]: HTML document, ISO-8859 text, with very long lines

[root@65be04194cde wse-back]# file src/Demiurgo/Taobao/Items/Crawler/[login to view URL]

src/Demiurgo/Taobao/Items/Crawler/[login to view URL]: HTML document, Non-ISO extended-ASCII text, with very long lines, with CRLF, LF line terminators

Evner: Linux, PHP, Scrapy, Web Crawling

Se mere: to â € ™, ã â â, php encoding

Om arbejdsgiveren:
( 5 bedømmelser ) Guadalajara, Mexico

Projekt ID: #18814291

Tildelt til:

programdev0001

Hi, Sir!! I am a new freelancer. You may doubt me because I have white history. BUT I have rich experience about PHP, html, SQL and etc.. i have been read your description carefully and i can do it wonderfully. I h Flere

$13 USD på 1 dag
(0 bedømmelser)
0.0

3 freelancere byder i gennemsnit $26 på dette job

bhaskarmandal

Hi, I am 5 years experienced web developer. I understand your point. I can complete this project within two hours . Please check my profile for my work quality . Thanks, Bhaskar Mandal

$30 USD in 0 dage
(84 bedømmelser)
6.1
arindampr

I have 2+year experience in PHP-MY SQL, I am interested about this job because I have team to handle this project carefully, so discuss more about this project massage me.

$35 USD in 10 dage
(1 bedømmelse)
2.4