Find a string in a select field and select it

SeoRoo

Client
Регистрация
12.09.2011
Сообщения
7
Благодарностей
0
Баллы
0
Hey Zennohero's,
i'm shortly before a suicide...

I'm working on a template with the Goal of mass submitting my sites to few webdirectorys. I have a txt-file with all the infos like title, description, contact infos aaaaand: the directory-categorie my site should be submitted to.

So in these example in the category-line stands: "Fernstudium;Weiterbildung;Studium". A macro will split at the ";". Now I've got a select field like these (I've shortend it) one:

HTML:
<select name="cat_id" gtbfieldid="2">
<option style="font-weight: bold;" value="149"> Auskunft &amp; Suchen</option>
<option value="156">-- Branchenverzeichnisse</option>
<option value="155">-- Datenbanken</option>
<option value="159">-- Lexika und Wissen</option>
<option value="152">-- Meta Suchmaschinen</option>
<option value="150">-- Suchmaschinen</option>
<option value="157">-- Telefonnummern</option>
<option value="154">-- Verbraucher</option>
<option value="151">-- Webkataloge</option>
<option value="153">-- Wetter</option>
<option value="158">-- Wirtschaftsauskünfte</option>
<option style="font-weight: bold;" value="1"> Auto &amp; LKW</option>
<option value="6">-- Abschleppdienste</option>
<option value="18">-- Auto Fanclubs</option>
<option value="20">-- Auto Portale und Foren</option>
<option value="42">-- Auto Tuning</option>
<option value="574">-- Auto und LKW Magazine</option>
<option value="14">-- Auto Vermietungen</option>
<option value="17">-- Auto Versicherungen</option>
<option value="9">-- Auto Werkstätten</option>
<option value="10">-- Auto Zubehör</option>
<option value="8">-- Autohersteller</option>
<option value="5">-- Autoreifen</option>
<option value="11">-- KFZ Sachverständige</option>
<option value="12">-- KFZ Zulassung</option>
<option value="575">-- LKW und Nutzfahrzeuge</option>
<option value="19">-- Oldtimer</option>
<option value="13">-- Online Autobörsen</option>
<option value="7">-- Sonstige Autoseiten</option>
<option value="583">-- Sonstige LKW Seiten</option>
<option value="21">-- Sportwagen</option>
<option style="font-weight: bold;" value="160"> Bildung</option>
<option value="161">-- Aus und Weiterbildung</option>
<option value="167">-- Berufsakademien</option>
<option value="166">-- Fachhochschulen</option>
<option value="162">-- Fernstudium</option>
<option value="163">-- Nachhilfe</option>
<option value="164">-- Schulen</option>
<option value="169">-- Sonstige Einrichtungen</option>
<option value="165">-- Universitäten</option>
<option value="168">-- Volkshochschulen</option>
<option style="font-weight: bold;" value="285"> Wellness</option>
<option value="290">-- Ayurveda</option>
<option value="287">-- Kosmetiksalons</option>
<option value="292">-- Massage</option>
<option value="293">-- Sauna</option>
<option value="286">-- Schönheitsfarmen</option>
<option value="295">-- Shiatsu</option>
<option value="289">-- Sonnenstudios</option>
<option value="291">-- Sonstige Wellness Seiten</option>
<option value="586">-- Wellness Magazine</option>
<option value="288">-- Wellnesshotels</option>
<option value="294">-- Yoga</option>
<option style="font-weight: bold;" value="667"> Menschen</option>
<option value="251">-- Anwaelte</option>
<option value="253">---- Anwalt und Notar in Berlin</option>
<option value="252">---- Anwalt und Notar in Bremen</option>
<option value="254">---- Anwalt und Notar in Hamburg</option>
<option value="256">---- Anwalt und Notar in Köln</option>
<option value="255">---- Anwalt und Notar in München</option>
<option value="665">---- Anwalt und Notar in Stuttgart</option>
<option value="186">-- Arbeit</option>
<option value="188">---- Arbeitnehmervertretungen</option>
<option value="195">---- Arbeitslos</option>
<option value="197">---- Arbeitsrecht</option>
<option value="187">---- Arbeitssicherheit</option>
<option value="192">---- Berufsbekleidung</option>
<option value="201">---- Berufswahl</option>
<option value="193">---- Bewerbung</option>
<option value="191">---- Elternzeit</option>
<option value="194">---- Existenzgründung</option>
<option value="200">---- Gehaltsrechner</option>
<option value="189">---- Gewerkschaften</option>
<option value="196">---- Hartz 4</option>
<option value="190">---- Mobbing</option>
<option value="198">---- Nebenjobs</option>
<option value="199">---- Zeitarbeit</option>
</select>
My next Milestone is to find the categorie (i.e.: "Fernstudium") in the big list of categorys...

Now: How can i search inside these select for one of the wanted category tags from my txt file and select that line to work on the further template... help me heros :-)
 

SeoRoo

Client
Регистрация
12.09.2011
Сообщения
7
Благодарностей
0
Баллы
0
For example, here is one of the sites:
worldwideweb.calibratedaudio.de/add_link.php?disable_ajax=1
 

archel

Client
Регистрация
02.05.2011
Сообщения
175
Благодарностей
22
Баллы
18
Should work like this, with some tuning up:

- pull out your keyword out of your text, let's say that is 'Auto Tuning'-

- get DOM/source of the page
in your case:
...
<option value="156">-- Branchenverzeichnisse</option>
<option value="155">-- Datenbanken</option>
<option value="159">-- Lexika und Wissen</option>
<option value="152">-- Meta Suchmaschinen</option>
<option value="150">-- Suchmaschinen</option>
<option value="157">-- Telefonnummern</option>
<option value="154">-- Verbraucher</option>
<option value="151">-- Webkataloge</option>
<option value="153">-- Wetter</option>
...


- then you regexp this. eg. if the category you pulled out of the text file is "Telefonnummern":
(?<=\<option\ value\=\").*?(?=\"\>--\ Telefonnummern\<\/option\>)

this will give you the value of this category, in this case: 157

- no just select the right category, using this number.
 
  • Спасибо
Реакции: SeoRoo

SeoRoo

Client
Регистрация
12.09.2011
Сообщения
7
Благодарностей
0
Баллы
0
hahahaaa genius!
big big big thanks! that's great!

I LOVE YOU :D
 

SeoRoo

Client
Регистрация
12.09.2011
Сообщения
7
Благодарностей
0
Баллы
0
Where the fck is the edit-button...

I've done those Steps, and it works great until the selection of the category.

If get the value of the option, for example 157, it did'nt select the option with the value 157, it selects the 157th item in the list. i've ad the short template... or i'am to tired to check how it works... :/
 

Вложения

archel

Client
Регистрация
02.05.2011
Сообщения
175
Благодарностей
22
Баллы
18
It's because they changed the order for some reason (probably to prevent spammers).

What I do then is extract the DOM until then selected category and then count the number of times you get value=
Don't know how to count it directly so I tried it another way.

See the template I added, it works perfectly for me.
Though you probably will have to change this:
(?<=\<DIV class\=addform_titel\>).*(?=Computerschulen und Nachhilfe)
since your DOM will be different probably.

Посмотреть вложение webkattest.xml
 

SeoRoo

Client
Регистрация
12.09.2011
Сообщения
7
Благодарностей
0
Баллы
0
Hey archel,
in my case it didn't work with your template ... but don't know why...

Doesn't think it will be so difficult before :/
 

Кто просматривает тему: (Всего: 1, Пользователи: 0, Гости: 1)