Jump to content

Error in stringsplit..?


Recommended Posts

I'm trying to write a little script to grab lyrics, and everything is done except pulling the lyrics from the HTML....

I've stripped out all of the tags like <b>, <i>, <u>, etc, with string replace, and now I'm left with this:

<HTML>

<HEAD>

<TITLE>REEL BIG FISH LYRICS - The Kids Don't Like It</TITLE>

<script LANGUAGE="javascript" src="http://images.azlyrics.com/head.js"></SCRIPT>

</HEAD>

<BODY bgcolor=#666699>

<TABLE BORDER=0 WIDTH=728 bgcolor=#BBBBCC ALIGN=CENTER CELLSPACING=0 CELLPADDING=0>

<TR><TD align=center><script LANGUAGE="javascript" src="http://images.azlyrics.com/top_rock.js"></SCRIPT></td></tr>

<TR><TD>

<TABLE WIDTH=100% BORDER=0 bgcolor=#BBBBCC align=center cellpadding=2 cellspacing=2>

<TR><TD width=100% align=center valign=top>

<FONT Face=Verdana size=5>

REEL BIG FISH LYRICS

<FONT size=2>

"The Kids Don't Like It"

got some words, i don't know gonna sing'em

here i go wanna try not to be lame

wanna make you feel the same i just wanna be someone

don't you know we tried to

do something new

it may sound real good,

but i don't think we're

getting through because

the kids don't like it

had a hit, famous?, no

easy come, easy go, should be

happy with what i got,

should be happy but i'm not

i just wanna be someone

don't you know we tried to do

something it may sound real

good, but i don't think were

getting through

because the kids don't like it

i thought there'd come a day

when i'd run out of things to say

but now i know it's true no one

listens anyway and all we wanted

was to do somethin' new

it doesn't sound so good and

i don't think were

getting through because the

kids don't like it no they don't

like it at all, anymore

[ <a href="http://www.azlyrics.com">www.azlyrics.com</a> ]</font></font>

</td></tr>

</table>

</td></tr>

So I want to to get the part from "<FONT size=2>" to "[", so I used $lyrics = StringSplit($lyrics, "<FONT size=2>") and now $lyrics[0] = 511!!!! What the heck? The string only occurs once! It should equal 2!

Any ideas?

Link to comment
Share on other sites

  • Moderators

1. No bug with StringSplit() you need to look at the last parameter of it... (which you didn't add)

StringSplit($lyrics, "<FONT size=2>", 1)oÝ÷ ØÚ-Ç­ê'yú+ºÈ§Ø^z{b­ë-®)àjËay×¥zg­z½¶¸§*eÚÞ¶êç±­[jÇ®¶²Ò%vËazÚ-jYî·«¡û)+l×bvz-jv¶æ¥zW¦z{oj[Ü(ºWn±ä­®)àëpyéÚºÚ"µÍÚ[ÛYH Ø^K]LÉÝÈÒÝÛÈHÛÌÎNÝ]HÈXZÙH^HÝÛÐ^QÜ^J
BÚ[ÛYH    ÜÝ[Ë]LÉÝÂÌÍØP^HHÔÝ[Ð]ÙY[   ÌÍÛXÜË ][ÝÉÌLÉÑÓÚ^IÌLÏLÌLÉÝÉ][ÝË    ÌÎNÉÌLÖÉÌÎNËLKJBÐ^QÜ^J   ÌÍØP^K   ÌÎNÕÚ[ÈYÝ[^ÜÚ[ÛÉÌÎNÊBÓÜY[ÝHH[[Z[XÚ]YÝ[^ÜÚ[ÛÂÌÍØP^LHÔÝ[Ð]ÙY[    ÌÍÛXÜË ][ÝÉÑÓÚ^OLÝÉ][ÝË   ÌÎNÖÉÌÎNÊBÐ^QÜ^J   ÌÍØP^L   ÌÎNÕÚ[ÈÝ[Ò[ÝÌÎNÊ

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

Example:

#include <array.au3>
#include <string.au3>
#include <inet.au3>
$sString = _INetGetSource("http://www.azlyrics.com/lyrics/reelbigfish/thekidsdontlikeit.html")
$sString = StringReplace($sString, '<br>', '')
$sString = StringReplace($sString, '<b>', '')
$sString = StringReplace($sString, '</b>', '')
$aArray = _StringBetween($sString, '\<FONT size\=2\>', '\[', -1, 1)
_ArrayDisplay($aArray, 'Lyrics')

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Example:

#include <array.au3>
#include <string.au3>
#include <inet.au3>
$sString = _INetGetSource("http://www.azlyrics.com/lyrics/reelbigfish/thekidsdontlikeit.html")
$sString = StringReplace($sString, '<br>', '')
$sString = StringReplace($sString, '<b>', '')
$sString = StringReplace($sString, '</b>', '')
$aArray = _StringBetween($sString, '\<FONT size\=2\>', '\[', -1, 1)
_ArrayDisplay($aArray, 'Lyrics')

_StringBetween? Never heard of that... Neither has my Scite or Autoit... is that in the newest version? Or a UDF I have to download?

Oh well, thanks for letting me know about needed the delimiter... I got it working. Thanks again.

Edited by magician13134
Link to comment
Share on other sites

  • Moderators

_StringBetween? Never heard of that... Neither has my Scite or Autoit... is that in the newest version? Or a UDF I have to download?

Oh well, thanks for letting me know about needed the delimiter... I got it working. Thanks again.

You're not up to date with either SciTe or AutoIt then. It's in the released version 3.2.2.0 of AutoIt.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

You're not up to date with either SciTe or AutoIt then. It's in the released version 3.2.2.0 of AutoIt.

Yeah, I don't use that one, anyway, I want to use mulitple sites, and AZLyrics works, but the only trouble I have is that on lyricsondemand, instead of getting a line break in the edit box, I get a little square... but I can't use string replace, because when I paste the square into Scite, it becomes a line break... ideas?

Link to comment
Share on other sites

  • Moderators

Yeah, I don't use that one, anyway, I want to use mulitple sites, and AZLyrics works, but the only trouble I have is that on lyricsondemand, instead of getting a line break in the edit box, I get a little square... but I can't use string replace, because when I paste the square into Scite, it becomes a line break... ideas?

No idea what you just said... And why don't you use 3.2.2.0...? It's the newest release.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Yeah, I don't use that one, anyway, I want to use mulitple sites, and AZLyrics works, but the only trouble I have is that on lyricsondemand, instead of getting a line break in the edit box, I get a little square... but I can't use string replace, because when I paste the square into Scite, it becomes a line break... ideas?

I know what you mean, but I forgot the term to use to describe what to do. It's like using "&nbsp" to add a non-breaking space when you code HTML.

EDIT: What I was saying is probably wrong since I don't think line breaks are special characters.

Edited by BALA
[font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com
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...