Home php Getting the content of the site https://www.transfermarkt.us/ (PARSING)

Getting the content of the site https://www.transfermarkt.us/ (PARSING)

Author

Date

Category

Dear colleagues. I need to paint on PHP website https://www.transfermarkt.us/ and its internal pages. Trying to do it in two ways:
1.

$ url = "www.transfermarkt.us";
$ H = FLE_GET_CONTENT ($ URL);

2.

$ url = "www.transfermarkt.us";
$ ch = curl_init ($ URL);
curl_setopt ($ CH, Curlopt_URL, $ URL);
CURL_SETOPT ($ CH, CURLOPT_SSL_VERIFYPEER, 0);
CURL_SETOPT ($ CH, CURLOPT_SSL_VERIFYHOST, 0);
CURL_SETOPT ($ CH, CURLOPT_FOLLOCATION, 1);
CURL_SETOPT ($ CH, Curlopt_returntransfer, True);
$ Header = Array (": Authority" = & gt; $ url,
"Method" = & gt; "Get",
": Method" = & gt; "Get",
": Path" = & gt; "/",
": Scheme" = & gt; "https",
"Accept" = & gt; "text / html, application / xhtml + xml, application / xml; q = 0.9, image / webp, image / apng, * / *; q = 0.8, application / signed-excchange; v = b3; q = 0.9",
"Accept-Encoding" = & gt; "Gzip, Deflate, BR",
"Accept-Language" = & gt; "RU-EN, RU; Q = 0.9, EN-US; Q = 0.8, EN; Q = 0.7, DA; Q = 0.6, pt; q = 0.5, hmn; q = 0.4, bg; q = 0.3",
"Cache-Control" = & gt; "Max-age = 0",
"Cookie" = & gt; "TMSESSID = p1agl77bld5hn3c0bsalapmkf6; _ga = GA1.2.1046738243.1587399746; OB-USER-TOKEN = bafe9ddd-194f-409a-982f-faf11dad10db; __gads = ID = 974a44ebcf9d6077: T = 1587399749: S = ALNI_MbT1rczgOOMGWQNmf7UZZ-Y0cTMnw; oil_data = {% 22opt_in % 22: True% 2c% 22Version% 22:% 221.3.2-Release% 22% 2c% 22LocalevariantName% 22:% 22Enen_01% 22% 2c% 22LocalevariantVersion% 22: 1% 2c% 22Custompurposes% 22: []% 2c% 22consentString% 22:% 22% 22% 2C% 22configVersion% 22: 1}; _gid = GA1.2.1714158336.1587676360; POPUPCHECK = 1587888244665; _gat = 1; ioam2018 = 0015b21390be3648e5e9dc373: 1616170946833: 1587399746833: .transfermarkt.us: 98: transfer : Home_Rest: NOEVENT: 1587815232473: AJSVRL ",
"Referer" = & gt; "https: //". $ URL,
"SEC-Fetch-Dest" = & gt; "Document",
"SEC-Fetch-Mode" = & gt; "Navigate",
"sec-fetch-site" = & gt; "SAME-ORIGN",
"sec-fetch-user" = & gt; "?1",
"Upgrade-Insecure-Requests" = & gt; "1",
"User-Agent" = & gt; "Mozilla / 5.0 (Windows NT 6.1; Win64; x64) AppleWebKit / 537.36 (KHTML, LIKE GECKO) Chrome / 80.0.3987.163 Safari / 537.36"
);
CURL_SETOPT ($ CH, CURLOPT_NOBODY, TRUE);
curl_setopt ($ CH, Curlopt_Header, 1);
CURL_SETOPT ($ CH, CURLOPT_HTTPHEADER, $ Header);
curl_setopt ($ CH, Curlopt_useragent, "Mozilla / 5.0 (Windows NT 6.1; Win64; x64) AppleWebKit / 537.36 (KHTML, LIKE GECKO) Chrome / 80.0.3987.163 Safari / 537.36");
$ H = CURL_EXEC ($ CH);

In both cases, I get an error Failed to Connect to www.transfermarkt.us: Connection Timed Out, although the page opens without problems in the browser. Do you tell me a decision?


Answer 1

curl_setopt ($ CH, CURLOPT_NOBODY, TRUE); – Remove if the body is needed, and you need it.

File_Get_Contents

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions