問題/質問
解析したいボット情報のデータベースがあります。RFC822 メッセージに似ていると言われています。
車輪を再発明して独自のパーサーを作成する前に、何か他のものが既に利用可能であるかどうかを確認することにしました。私はimap_rfc822_parse_headers()
、まさに私が望むことをしているようです。残念ながら、IMAP 拡張機能は私の環境では利用できません。
オンラインや Stack Overflow で多くの代替案を見てきました。残念ながら、それらはすべて電子メール用に構築されており、必要以上のことを行っています... 多くの場合、電子メール全体を解析し、特別な方法でヘッダーを処理します。これらのヘッダーを便利なオブジェクトまたは配列に単純に解析したいだけです。
利用可能なストレートPHPバージョンimap_rfc822_parse_headers()
、またはこのようなデータを解析する同等のものはありますか? そうでない場合は、自分で書きます。
サンプルデータ
robot-id: abcdatos
robot-name: ABCdatos BotLink
robot-from: no
robot-useragent: ABCdatos BotLink/1.0.2 (test links)
robot-language: basic
robot-description: This robot is used to verify availability of the ABCdatos
directory entries (http://www.abcdatos.com), checking
HTTP HEAD. Robot runs twice a week. Under HTTP 5xx
error responses or unable to connect, it repeats
verification some hours later, verifiying if that was a
temporary situation.
robot-history: This robot was developed by ABCdatos team to help
working in the directory maintenance.
robot-environment: commercial
modified-date: Thu, 29 May 2003 01:00:00 GMT
modified-by: ABCdatos
robot-id: acme-spider
robot-name: Acme.Spider
robot-cover-url: http://www.acme.com/java/software/Acme.Spider.html
robot-exclusion: yes
robot-exclusion-useragent: Due to a deficiency in Java it's not currently possible to set the User-Agent.
robot-noindex: no
robot-host: *
robot-language: java
robot-description: A Java utility class for writing your own robots.
robot-history:
robot-environment:
modified-date: Wed, 04 Dec 1996 21:30:11 GMT
modified-by: Jef Poskanzer
...