Открываем браузер через php

Как открыть браузер на PHP?

Я здесь, чтобы снова задать глупый вопрос. Это связано с моими предыдущими вопросами.

В настоящее время я нашел способ flash/flex отправить видеофайл (в byteArray) на php. Где php получает и записывает его в локальную систему, затем отправляет его на сервер youtube автоматически через скрипт. Это все бэкэнд, хотя у меня нет способа проверить, был ли видео файл успешно загружен на YouTube, чем проверить его вручную на YouTube.

Так что я думаю о новом PHP-скрипте, где он получит и запишет видеофайл с flash. Затем откройте окно браузера, где оно автоматически загрузит видео и одновременно отследит его через браузер с его статусом, используя, возможно, отладочные отпечатки.

Я только еще учусь php. Я пытался провести некоторое исследование по этому вопросу, но безуспешно. Надеюсь, вы можете помочь мне, ребята. Благодарю.

3 ответа

PHP-код работает на вашем веб-сервере. Это код, работающий на другом компьютере. Он не может ничего открыть на вашем компьютере. Если бы это было возможно, я также смог бы открыть окна на вашем компьютере с того, на котором я печатаю, и у вас возникли бы серьезные проблемы. К завтрашнему дню все люди в мире будут захвачены или уничтожены своими компьютерами другими случайными людьми в Интернете.

PHP на стороне сервера, вы не можете напрямую использовать какой-либо код PHP для управления работой браузера на стороне клиента. Вам нужно прибегнуть к технологиям на стороне клиента, таким как Flash и JavaScript.

Читайте также:  Postgresql database driver java

Источник

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

A scriptable browser for PHP. Browse on the web, download files, fill and submit form !

License

sarigue/PHPBrowser

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Sign In Required

Please sign in to use Codespaces.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

README.md

PHPBrowser and BrowserShell

A scriptable browser in PHP and his CLI !

You can browse to the web, and fill and submit forms.

You can call the browser’s methods from your PHP scripts, or you can execute them from STDIN ou from a batch file.

Browser.php is the browser, to make web requests. BrowserShell.php is a shell to control Browser.php

Browser on your PHP script:

require_once 'lib/Browser.php' 
php BrowserShell.php --stdin 
php BrowserShell.php --file= [--config=] [--pause=] [--debug=1|0] 
browse : Browse to an URL submit : Submit a form. Can be followed by DOM-Element's name or #ID (start with #) write : Write the response's body to file print : Show the response's body history : Browse in browser's history use-form : Select a form to use (by name or ID. If empty, use the first form) reset : Reset the form set : Set a field value by name = value or #ID = value unset : Remove a field element of the sent data check : Check the checkbox (by name or #ID). Equivalent of set NameOr#ID on uncheck : Uncheck the checkbox (by name or #ID). Equivalent of unset NameOr#ID set-var : Set a reusable script variable will be call by include : Include and execute an another batch file message : Print a message debug : Print a message if debug=1 
browse http://www.google.fr Load webpage http://www.google.fr include commandes.browser Run commands wich are defined in commandes.browser file use-form Select the first form (optional. It is automatic) use-form formName Select the form with name "formName" use-form #formID Select the form with ID "formID" submit Submit form submit submitButton Submit form with button with name "submitButton" submit #submitBtnId Submit form with button with ID "submitBtnId" write filePath Write the responses' body to "filePath" history goto:[label] Go to label "label" (like a click in your browser's history) history -1 Go back to the previous page - Resend the form history back Go back to the previous page - Resend the form history +1 Go to the next page - Resend the form history forward Go to the next page - Resend the form history 0 Reload current page - Resend the form history reload Reload current page - Resend the form history -5 Go to 5 previous pages - Resend the form history +2 Go to 2 following pages - Resend the form history [param] browse Like "history . " but with a GET request (no re-sending the form) reset Reset current form set name = value Set "value" to the field named "name" set #id = value Set "value" to the field with ID "id" set name = ["a", "b"] Set an array of values to field named "name" set name = "["a", "b"]" Set a string value '["a", "b"]' to the field named "name" check mycheckbox Check the checkbox named "mycheckbox" check #checkboxUD Check the checkbox with id "checkboxID" uncheck mycheckbox Uncheck the checkbox named "mycheckbox" uncheck #checkboxUD Uncheck the checkbox with id "checkboxID" unset name The field named "name" will not sent on submit unset #id The field with ID "id" will not sent on submit set-var variable = val Set the value "val" to variable named "variable". will return "val" print my message Show "my message" with line feed print Show only an empty line debug debug message Show "debug message" if debug = 1 debug Show an empty line if debug = 1 

You can use Label / Commands’ group with :

You can use go to label (browser’s history) with :

Источник

Эмуляция браузера на php или парсер без проблем

Внимание! На самом деле библиотека не умеет эмулировать работу браузера. Это был маркетинговый ход, а я в 2009 году не понял этого, ибо был молод и не опытен. Это обычная библиотека упрощающая разбор веб-страницы, для тех кто не силен в регулярках. Нужна она для парсинга.

Не так давно столкнулся с одной задачкой. Надо было взять 1000 урлов из поиска Яндекса и проверить наличие определенных признаков (строк) на странице. Пытался все сделать с помощью стандартной функции fsockopen, но возникла проблема — 70-80% серверов меня приравнивали к ДДОС атаке и банили по IP. Убил часа 2-3 на подборы различных User-Agent, но меня всеравно причисляли к вредителям и блокировали.

В результате я наткнулся на библиотеку snoopy.php, которая позволяет эмулировать работу браузера. Там мощный набор функций не только для эмуляции браузера, а еще и для нормального парсинга сайтов.

snoopy

Вот основной перечень полезных функций этого парсера:

  • $snoopy->fetch(«http://www.php.net/»);
    Отправляем запрос по интересующему нас урлу и получаем в ответ все содержимое страницы
  • $snoopy->fetchtext(«http://www.php.net/»);
    После отправки запроса получаем только текст, который на странице. Т.е. все теги, картики и скрипты вырезаются.
  • $snoopy->fetchlinks(«http://www.php.net/»);
    Получаем массив с урлами ссылок, которые находятся на интересующей нас странице

И перечень основных переменных этого класса:

  • $snoopy->results;
    Переменная в которую записывается результат работы предыдущих функций. Она может вернуть строку или массив, в зависимости от того, что хотим получить.
  • $snoopy->agent;
    User-agent, который быдет передаваться при отправке наших запросов.
  • $snoopy->referer;
    Поле реферера, которое будет передано запрашиваемому серверу. Его можно использовать, например, чтобы создавать видимость переходов по ссылкам внутренней навигации сайта.

Также с помощью этой библиотеки можно не только обращаться к страницам, но еще и эмулировать отправку html форм. Видимо создавать post запрос.

Источник

Оцените статью