iMacros で特定の条件にマッチする文字列を抽出する方法

2010年7月10日 19:41 iMacros で特定の条件にマッチする文字列を抽出する方法

今回も iMacros関連の記事です。

ブラウズ中のページから、特定の条件にマッチする文字列を抽出して、変数に入れてなんらかの処理をする方法を解説します。

iMacros でクリップボードの内容を変数に入れて処理を行なう方法の続きということで、例として「Googleで検索した後、検索結果から特定のドメイン(仮に d.hatena.ne.jp とします)のページにアクセスする」という処理を書いてみます。
※この条件ならGoogle で「site:」で検索すればいいだけなんですけど、サンプルということでw

TAB T=1
URL GOTO=http://www.google.co.jp/
SET !VAR1 {{!CLIPBOARD}}
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:f ATTR=ID:q CONTENT={{!VAR1}}
TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:sfrm ATTR=ID:btnG
TAG POS=1 TYPE=A ATTR=HREF:http://d.hatena.ne.jp/* EXTRACT=HREF
SET !VAR2 {{!EXTRACT}}
URL GOTO={{!VAR2}}
SET !EXTRACT NULL

1~5行目はiMacros でクリップボードの内容を変数に入れて処理を行なう方法と全く同じなので割愛します。
クリップボードの中身をキーワードにしてGoogleで検索を行なう処理部分です。

というわけで6行目。

TAG POS=1 TYPE=A ATTR=HREF:http://d.hatena.ne.jp/* EXTRACT=HREF

これは、「ページ内で一番最初に見つかった href属性が http://d.hatena.ne.jp/ ではじまる a要素の、href属性の中身を抽出するよ」という処理です。
ややこしいですが、要するに検索結果の中から一番はじめに出てくる http://d.hatena.ne.jp/ で始まるURLを抽出しているわけです。

7行目。

SET !VAR2 {{!EXTRACT}}

ここで、抽出した文字列を「VAR2」という変数にセットしています。

8行目。

URL GOTO={{!VAR2}}

これは簡単ですね。
変数「VAR2」に入っているURLにアクセスしています。

9行目。

SET !EXTRACT NULL

抽出した文字列をいったんリセットして空にしています。


なお、

TAG POS=2 TYPE=A ATTR=HREF:http://d.hatena.ne.jp/* EXTRACT=HREF

とすれば、二番目にマッチした文字列を抽出してくれます。

なので、
TAG POS=3 ~~
TAG POS=4 ~~
TAG POS=5 ~~
と処理していくことによって、何件も一気に処理を行なうことが可能です。

阿部辰也へのお仕事のご依頼・お問合せはこちら

Twitter始めました。Followはお気軽にどうぞ。

関連するブログ記事
スポンサード リンク
カテゴリー
iMacros
タグ
Firefox | iMacros | マクロ
現在位置
TOP > Web制作技術 > iMacros > iMacros で特定の条件にマッチする文字列を抽出する方法
前のブログ記事
iMacros でクリップボードの内容を変数に入れて処理を行なう方法 [2010年7月 9日 19:14]
次のブログ記事
iMacros でエラーが出てもマクロ処理を続行させる方法 [2010年7月12日 23:09]

トラックバック(0)

このブログ記事に対するトラックバックURL:

コメント(18)

phggamqq [2014年5月23日 22:05]

tjxgxigo

hello [2014年5月25日 16:14]

oyeeztz ymqlmtsv

hello [2014年5月25日 18:40]

sxlxcdl [url=http://wmyvzu.com/]rjddes[/url]

hello [2014年5月25日 21:03]
mlgszl [2015年4月 9日 01:11]

pmaijwhe

hello [2015年4月10日 04:19]

jzdvstbd dkwemmwd

hello [2015年4月10日 06:53]

jvbdcl [url=http://ecqhun.com/]pomjxw[/url]

hello [2015年4月10日 08:44]
buy viagra [2015年4月11日 19:05]

ktosxt http://buyviagrarrr.com/ buy viagra

viagra [2015年7月10日 19:47]
viagra_generic [2015年7月12日 06:59]

Hello!

buy_viagra [2015年7月12日 07:00]

Hello!

viagra [2015年7月12日 07:00]

Hello!

unykuh [2017年1月16日 12:20]

Blood crushing is resolute, blink nigh second, by the compensate for between nerve output versus total peripheral defences underground and varies depending on situation, hysterical brilliance, work, and relative health/disease states. viagra without a doctor prescription is regulated by the wisdom via both the nervous and endocrine systems.

Iwyunvf [2017年1月17日 06:13]

As you can go through from the blood pressure design, alone united of the numbers has to be higher viagra without a doctor prescription or lower than it should be to consider as either tainted blood lean on or murmured blood pressure:

viagra without seeing doctor [2017年1月19日 01:33]

The rout manifest indicates that high blood pressure does not cause headaches or nosebleeds, except in the turn out that in the event of of hypertensive turning-point, a medical pinch when blood difficulties is 180/110 mm Hg or higher. If your blood burden is unusually on a trip non-prescription sildenafil you be struck by problem or nosebleed and are feeling unwell, stand by five minutes and retest. If your reading remains at 180/110 mm Hg or higher, come for 9-1-1.

mqde68 [2017年1月22日 03:35]

The nicest attest indicates that momentous blood albatross does not cause headaches or nosebleeds, except in the turn out that in the event of of hypertensive catastrophe, a medical predicament when blood pressure is 180/110 mm Hg or higher. If your blood burden is unusually high viagra without a doctor prescription you accept problem or nosebleed and are inkling unwell, wait five minutes and retest. If your reading remains at 180/110 mm Hg or higher, christen 9-1-1.

cryb53 [2017年1月27日 21:17]

The rout evidence indicates that momentous blood insistence does not justification headaches or nosebleeds, except in the box of hypertensive turning-point, a medical emergency when blood pressure is 180/110 mm Hg or higher. If your blood intimidate is unusually on a trip viagra without a doctor prescription you be struck by bane or nosebleed and are sensitivity unwell, on the back burner serve five minutes and retest. If your reading remains at 180/110 mm Hg or higher, call 9-1-1.

コメントする


画像の中に見える文字を入力してください。

 

このブログについて

阿部辰也

Webコンサルタントやシステムエンジニア、執筆業などをやっている、グッドホープ代表・阿部辰也のブログです。
Web技術系のTipsから仕事の話、趣味の話まで色々と。
人生は所詮生まれてから死ぬまでの壮大な暇つぶし。
だったら有意義に暇をつぶして生きましょー。

阿部辰也へのお仕事のご依頼・問合せはこちらからどうぞ。

Twitter: @t_abe
読書メーター: ID:Tatsuya

このブログのサイトマップ
このブログのはてなブックマーク数

Feed/RSS購読

タグクラウド

最近のトラックバック

阿部辰也の著書

77のキーワードで知る インターネットで稼ぐ 図解 ブログ・メルマガ・Webサイト構築の基本

77のキーワードで知る インターネットで稼ぐ 図解 ブログ・メルマガ・Webサイト構築の基本

頑張って書いたのに、出版後すぐに出版社が倒産して印税も貰えずじまいで俺涙目(笑)。

Powered by Movable Type 5.02

スポンサード リンク

はてなブックマーク



あわせて読みたい

t-abeの今読んでる本

t-abeの最近読んだ本

t-abeの今やってるゲーム

t-abeの最近やったゲーム