Мой массив URL-адресов содержит около 100 URL-адресов и получает информацию от API, предназначенного для чего-то подобного.
В любом случае, около 50% URL-адресов возвращаются
400 Bad Request
Your browser sent a request that this server could not understand.
GET /player/euw/Wolves Deficio/ingame HTTP/1.1
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1
Host: api.captainteemo.com
Accept: */*
URL-адреса верны на 100 %, потому что, когда я копирую их в свой браузер, я ДЕЙСТВИТЕЛЬНО получаю информацию.
Вот мой код:
function get_data($urls) {
// spoofing FireFox 2.0
$useragent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1";
$ch = curl_init();
// set user agent
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
if(is_array($urls)) {
$output = array();
foreach($urls as $url) {
// set the rest of your cURL options here
curl_setopt($ch, CURLOPT_URL, $url);
//return the transfer as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// $output contains the output string
array_push($output, curl_exec($ch));
}
}
else {
// set the rest of your cURL options here
curl_setopt($ch, CURLOPT_URL, $urls);
//return the transfer as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// $output contains the output string
$output = curl_exec($ch);
}
// close curl resource to free up system resources
curl_close($ch);
return $output;
}
Подробнее здесь: https://stackoverflow.com/questions/159 ... ad-request
Пытаюсь получить информацию из массива URL-адресов с помощью cURL, получаю неверный запрос ⇐ Php
Кемеровские программисты php общаются здесь
1737433117
Anonymous
Мой массив URL-адресов содержит около 100 URL-адресов и получает информацию от API, предназначенного для чего-то подобного.
В любом случае, около 50% URL-адресов возвращаются
400 Bad Request
Your browser sent a request that this server could not understand.
GET /player/euw/Wolves Deficio/ingame HTTP/1.1
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1
Host: api.captainteemo.com
Accept: */*
URL-адреса верны на 100 %, потому что, когда я копирую их в свой браузер, я ДЕЙСТВИТЕЛЬНО получаю информацию.
Вот мой код:
function get_data($urls) {
// spoofing FireFox 2.0
$useragent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1";
$ch = curl_init();
// set user agent
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
if(is_array($urls)) {
$output = array();
foreach($urls as $url) {
// set the rest of your cURL options here
curl_setopt($ch, CURLOPT_URL, $url);
//return the transfer as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// $output contains the output string
array_push($output, curl_exec($ch));
}
}
else {
// set the rest of your cURL options here
curl_setopt($ch, CURLOPT_URL, $urls);
//return the transfer as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// $output contains the output string
$output = curl_exec($ch);
}
// close curl resource to free up system resources
curl_close($ch);
return $output;
}
Подробнее здесь: [url]https://stackoverflow.com/questions/15952679/trying-to-get-information-from-urls-array-using-curl-getting-bad-request[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия