Jump to content

StringReplace in a URL


Recommended Posts

$source = _IEDocReadHTML($oIE)
$mail = StringRegExp($source, 'href="(/login/read_mail.php?id=\d+?)"', 3)
$source = StringReplace($mail, "=", "\d+?")

After ID it's a number like 2905 so tell me if my StringRegExp is wrong but my question is :

For the string replace my script is good ? because after that i want IE go to this URL and do an action for all of the url is the same, what i have decieded so i need a table or anything ?

Can you help me

You have see my very bad english Hein ? Sorry ...

Link to comment
Share on other sites

Hi,

StringRegExp with parameter 3 returns an array. You need a loop to replace the values.

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

Sure ...

$source = 'href="(/login/read_mail.php?id=3907 bla href="(/login/read_mail.php?id=2000 blubb href="(/login/read_mail.php?id=1337jkbku href="(/login/read_mail.php?id=3456ji  )'
$id_A = StringRegExp($source, '/login/read_mail\.php\?id=(\d+)', 3)

For $i = 0 To UBound($id_A) - 1
    ; replace or whatever
    ConsoleWrite($id_A[$i] & @CRLF)
Next

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

That StringReplace is never going to work for what you want. You are mixing StringREplace with StringRegExpReplace. Show us what you want to do and we can give you a more definitive reply. You may not even need the StringRegExp() just a StringRegExpReplace to get what you want.

We need some example of what you are reading and an example of what you expect.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

That StringReplace is never going to work for what you want. You are mixing StringREplace with StringRegExpReplace. Show us what you want to do and we can give you a more definitive reply. You may not even need the StringRegExp() just a StringRegExpReplace to get what you want.

We need some example of what you are reading and an example of what you expect.

Ok i will trie so i want in a page, download all of the link like http://www.******************/login/read_mail.php?id=2960, only the number of id change that can be 2961 or 2870. So after have download all of the link of this type go this different link and do only one action who is the same for all the links.

Once again sorry for my english :s

Link to comment
Share on other sites

That doesn't help at all.

Do you know how to get the page source? Copy and paste the relevant part of that into a post so we can see that we are actually working with here. If it contains personal dedails then replace those with some random text strings. We need to know what you are working with and what you expect to happen with that.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Yes i know !

<table cellspacing = "0" cellpadding = "0" class = "mail_list">
<tr>
<td valign = "top" class = "header subject">Sujet</td>
<td valign = "top" class = "header days_active">Jours actifs </td>
<td valign = "top" class = "header read">A lu</td>
</tr>
<tr>
<td valign = "top"><a href = "/login/read_mail.php?id=2617" target = "_blank" > remportez un Home cinéma Philips</a>

</td>
<td valign = "top">7</td>
<td valign = "top">Non</td>
</tr>
<tr>
<td valign = "top" colspan = "3"><hr/></td>
</tr>
<tr>
<td valign = "top"><a href = "/login/read_mail.php?id=2621" target = "_blank" >gagnez de l'argent en vous amusant !</a>
</td>
<td valign = "top">7</td>
<td valign = "top">Non</td>

</tr>
<tr>
<td valign = "top" colspan = "3"><hr/></td>
</tr>
<tr>
<td valign = "top"><a href = "/login/read_mail.php?id=2597" target = "_blank" > tentez de gagner l'iPhone4 !</a>
</td>
<td valign = "top">6</td>
<td valign = "top">Non</td>
</tr>
<tr>
<td valign = "top" colspan = "3"><hr/></td>
</tr>
<tr>

<td valign = "top"><a href = "/login/read_mail.php?id=2603" target = "_blank" > inscrivez vous et recevez un bon d'achat de 10 euros !</a>
</td>
<td valign = "top">5</td>
<td valign = "top">Non</td>
</tr>
<tr>
<td valign = "top" colspan = "3"><hr/></td>
</tr>
<tr>
<td valign = "top"><a href = "/login/read_mail.php?id=2596" target = "_blank" > votre mutuelle santé à partir de 5.72 euros par mois </a>
</td>
<td valign = "top">4</td>

<td valign = "top">Non</td>
</tr>
<tr>
<td valign = "top" colspan = "3"><hr/></td>
</tr>
<tr>
<td valign = "top"><a href = "/login/read_mail.php?id=2612" target = "_blank" > tentez de gagner une Toyota Aygo pour 3€ !</a>
</td>
<td valign = "top">4</td>
<td valign = "top">Non</td>
</tr>
<tr>
<td valign = "top" colspan = "3"><hr/></td>

</tr>
<tr>
<td valign = "top"><a href = "/login/read_mail.php?id=2595" target = "_blank" > recevez 5.000 perles en participant au jeu concours Gaz de France Dolcevita !</a>
</td>
<td valign = "top">3</td>
<td valign = "top">Non</td>
</tr>
<tr>
<td valign = "top" colspan = "3"><hr/></td>
</tr>
<tr>
<td valign = "top"><a href = "/login/read_mail.php?id=2579" target = "_blank" > transformez vos impôts en patrimoine : simulation gratuite ! </a>
</td>

<td valign = "top">3</td>
<td valign = "top">Non</td>
</tr>
<tr>
<td valign = "top" colspan = "3"><hr/></td>
</tr>
<tr>
<td valign = "top"><a href = "/login/read_mail.php?id=2590" target = "_blank" > profitez dés à présent des  7€ offerts !</a>
</td>
<td valign = "top">2</td>
<td valign = "top">Non</td>
</tr>

<tr>
<td valign = "top" colspan = "3"><hr/></td>
</tr>
<tr>
<td valign = "top"><a href = "/login/read_mail.php?id=2566" target = "_blank" > profitez de jusqu'à - 70 pourcent de réduction !</a>
</td>
<td valign = "top">1</td>
<td valign = "top">Non</td>
</tr>
</table>

Here the page source, so i want visit all of the link like "/login/read_mail.php?id=****" and for this link do a unique action

Link to comment
Share on other sites

YAB = Yet Another Bot

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...