Forums > Javascript

find pictures from internetsides

February 17, 2009 | 2:50 pm

Hello,

Im havin a problem with my code. I want to build a programm that finds all the pictures on an internetside i choose and downloads them. The first problem is to find
the pictures. Thats what im trying to do here:

//picfind.js
//
//finds pictures in source code

inlets =1;
outlets=1;

var httppos;

var jpgpos;

var z;
//this is the var for the string im putting in

function god(z) {
//I give it the name god

for (var ti = 0; ti < = z.length; ti++){

if (z.substring(ti,ti+7)=="http://") {

httppos=ti;

}

if (z.substring(ti,ti+4)==".jpg") {

jpgpos=ti+4;

outlet(0,z.substring(httppos,jpgpos));

}

}

}

this works really good for things like that:

wnuciwefncw…(()))888eiunwediuntrastrashtrashdasdadhttp://lol.jpgtrashtrashtrashdasdasd

the output ist http://lol.jpg

but when I put in some sourcecode from a homepage I get this:

width:1px: no such object
height:1px: no such object
top:-1000em: no such object
overflow:hidden}.f{color:#666}.flc: no such object
a.fl{color:#77c}a: no such object
.w: no such object
.q:visited: no such object
.q:active: no such object
.q: no such object
.b: no such object
.b: no such object
color:#000: no such object
padding:5px: no such object
.n: no such object
.b: no such object
cursor:hand}.ta{padding:3px: no such object
#tpa3{padding-top:9px}#gbar{height:22px: no such object
padding-left:2px}.gbh: no such object
.gbd{border-top:1px: no such object
font-size:1px}.gbh{height:0: no such object
position:absolute: no such object
top:24px: no such object
width:100}#gbi: no such object
#gbs{background:#fff: no such object
left:0: no such object
position:absolute: no such object
top:24px: no such object
visibility:hidden: no such object
z-index:1000}#gbi{border:1px: no such object
border-color:#c9d7f1: no such object
z-index:1001}#guser{padding-bottom:7px: no such object
#guser{font-size:13px: no such object
padding-top:1px: no such object
.gb3{height:22px: no such object
margin-right:.73em: no such object
vertical-align:top}#gbar{float:left}}.gb2{display:block: no such object
padding:.2em: no such object
a.gb2: no such object
a.gb3{color:#00c: no such object
.gb3{text-decoration:none}a.gb2:hover{background:#36c: no such object
color:#fff: no such object
font-style:normal}body: no such object
td: no such object
div: no such object
.p: no such object
a{font-family:arial: no such object
sans-serif}#sd{font-size:84o such object

(plenty lines of nothing)

2009: not a symbol

————–
for some reason it tries to understand the string, I think.
Does anybody knows what im doing wrong here ?

greetz


February 17, 2009 | 6:23 pm

Would it be possible that you would have some semi colon, and that you display that in a message box that you trigger? That’s only a speculation though.


February 17, 2009 | 11:10 pm

yeah…you are right

it doesnt like semi colons
i found out that it also doesnt like whitespaces

thanks alot ;)

hmmmm…think think
but what can i do to avoid that ?


February 17, 2009 | 11:20 pm



sxa
February 18, 2009 | 11:50 am

why not use regular expressions (ie the RegExp object) instead of having to roll your own text scanner?

http://www.javascriptkit.com/jsref/regexp.shtml


February 19, 2009 | 4:38 pm

You might find your life will be a lot easier if you use the shell and use wget, which has lots of convenient settings to filter filetypes. that’s what I did for a similar project a few years ago.

M


February 22, 2009 | 11:15 pm

hmm, i tried something with regexp.
but theres always the semi colon problem

– Pasted Max Patch, click to expand. –

February 23, 2009 | 12:22 am

Dieter_Laser wrote on Mon, 23 February 2009 00:15hmm, i tried something with regexp.
but theres always the semi colon problem

The message box with the semi colon needs to be quoted or have the semi-colon escaped, which is hopefully what you’ll get in the normal life using jit.uldl and jit.text.

– Pasted Max Patch, click to expand. –

ej


March 10, 2009 | 2:22 pm

Hi, its me again

hmm, when i press bang my max always crashes.
its working for decimal and hex for me. but not with ascii.

the thing is, that i want to make this with max.
so what do you suggest is the best way ?

– Pasted Max Patch, click to expand. –

thanks


March 11, 2009 | 9:48 am

EEEEHHHHHHHHHH

nice

– Pasted Max Patch, click to expand. –

Man, max is soo big !



Ad.
April 27, 2009 | 7:10 pm

Hi.
I have this error :
jit.str.regexp: PCRE error -10

Some knows about it ?

10.5, macbook pro

Ad


April 27, 2009 | 7:59 pm

Yeh I’ve come across that error before but the cause appears to be a mystery. One way of solving it that has worked for me is to open the [jit.textfile] after you have downloaded from [jit.uldl] and before you send it a bang. Using something like [t b wclose open] with all the outlets connected to the [jit.textfile] should do it. No idea why this seems to work though.

lh



Ad.
April 27, 2009 | 8:26 pm

Works fine, thanks !
Ad


April 29, 2009 | 6:29 pm

Here’s my version of this fix with included dropfile for specifying where to save images.

Enjoy and thanks so much for the fix in the first place!

– Pasted Max Patch, click to expand. –

Viewing 14 posts - 1 through 14 (of 14 total)