First of all, I don't need the code, it would be rude to ask. I just need to know the best way to achieve this. I'm trying to make a tool that downloads every possible photo-answer of an Ask.Fm profile given the url of the profile.
I think the best solution would need one or two asynchronous threads, I'm not sure yet.
First Thread
Option A: This thread should get the links from the profile page and push them in a List
. When it finishes processing the page, it emulates a button click ("View more") and goes on searching for other links, and so on (there is no page 2, AJAX script adds elements to the page when you click that button).
Option B: Maybe this thread should instead emulate a lot of clicks first, until the button disappears, when you have reached something like one year old answers. And then with a single foreach
and a Regex
filter it would be easy to get all links. But with this option I wouldn't have links as soon as possible, instead I would get them all at the end of its clicking job, and that would take time, because I think you have to wait some milliseconds to avoid bugs invoking buttons too fast.
Making a custom List
with an OnAdd
event would allow to process every link that is coming from the first thread, or maybe just checking every 5 seconds with a standard list would be easier, I don't know. I don't even know if I should use arrays (I come from C++).
- Should I use a separate thread and all this
List
thing to download all the links that the first thread is getting, or is this stupid and I can just download right after I find a link? Wouldn't that be too memory expensive? - I'm sure I need at least one asynchronous thread. I don't want the form to freeze til the end of script. But I don't know what's the best multithreading option. What do you suggest?
- Should I use
Lists
? Custom lists withOnAdd
event? Arrays? - Most important: Do you know other better ways to achieve all this?
Thank you in advance, Neflux.