login about faq
#include <CkSpider.h>

void ChilkatSample(void) { // The Chilkat Spider component/library is free. CkSpider spider;

//  The spider object crawls a single web site at a time.  As you'll see
//  in later examples, you can collect outbound links and use them to
//  crawl the web.  For now, we'll simply spider 10 pages of chilkatsoft.com
spider.Initialize("www.chilkatsoft.com");

//  Add the 1st URL:
spider.AddUnspidered("http://www.chilkatsoft.com/");

//  Begin crawling the site by calling CrawlNext repeatedly.
long i;
for (i = 0; i <= 9; i++) {
    bool success;
    success = spider.CrawlNext();
    if (success == true) {
        //  Show the URL of the page just spidered.
        printf("%s\n",spider.lastUrl());
        //  The HTML is available in the LastHtml property
    }
    else {
        //  Did we get an error or are there no more URLs to crawl?
        if (spider.get_NumUnspidered() == 0) {
            printf("No more URLs to spider\n");
        }
        else {
            printf("%s\n",spider.lastErrorText());
        }

    }

    //  Sleep 1 second before spidering the next URL.
    spider.SleepMs(1000);
}

}

Need help ~ can somebody confirm this codes works on Windows XP. If it doesn't, is there a way to make it? If you could provide a working code that would be excellent.

asked Mar 18 '13 at 22:40

GaGoKoYa's gravatar image

GaGoKoYa
1223

edited Mar 18 '13 at 22:53


Do you get a compile error? What is the output when you run the program?

link

answered Mar 19 '13 at 05:49

Gert's gravatar image

Gert ♦
629141824

Nope ~ I manage to compile it without errors or warning, at least that was the build log says. It just stop after I tried to run the .exe file saying xxx.exe has encountered a problem and needs to close... Supposedly it should returns the urls that it finds.

(Mar 19 '13 at 22:58) GaGoKoYa

I don't know the spider classes, but maybe you can sprinkle some debugging printf statements in the code so we see where it crashes?

(Mar 20 '13 at 02:10) Gert ♦

@Gert ^^ looks like we have the same idea on how to look for the crash starter. I've posted a sample at http://www.cplusplus.com/forum/beginner/96083/ --> tweaked it so many times now. If I did something silly in the code please do correct me.

(Mar 20 '13 at 03:25) GaGoKoYa

Instead of

printf("started");
You may want to try
fprintf(stderr, "At point 1\n");
because printf may buffer output. fprintf(stderr,....) will never buffer and print immediately. The \n will force a newline.

(Mar 20 '13 at 03:33) Gert ♦

Tried the fprinf(stderr,) ~ still just shows 1 print then the program stopped. Well I've asks a few of my friends to test it, one managed to get it working up to certain point. He was using windows 7 and visual studio. But I still need to know the real problem before I can sleep peacefully. Any ideas? so I can dig google.

(Mar 20 '13 at 22:25) GaGoKoYa

Well gonna say that it works on linux with minor correction. On windows (tried on windows XP) seems to be a bit hard to get it working (still not working for me), so I'll put a pause on it.

Anyone that can help, just post a working (on windows plaform) codes here ^^

link

answered Mar 24 '13 at 22:31

GaGoKoYa's gravatar image

GaGoKoYa
1223

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×65
×13

Asked: Mar 18 '13 at 22:40

Seen: 1,262 times

Last updated: Mar 24 '13 at 22:31

powered by OSQA