Web scraping using perl [closed] - perl

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I might ask something stupid but I want to learn some web scraping. I already know how to use perl, so I would prefer to do it using this language. I know there are a lot of modules on CPAN, I tried to read those but I barely understand something. I haven't found anthing that would explain from zero what this process means. I could use some help with some links or some materials to study a little web scraping.
Thanks!

At a pretty basic level, 'web scraping' is just downloading a webpage, and parsing it to extract the information you want. At a started level, the module you want is LWP that lets you fetch content, and then 'something' to extract the information you want. HTML::Parser or HTML::TableExtract for example. There's nothing to say you can't roll your own using pattern matching of course, but ... well, processing HTML isn't a new problem, so why re-invent the wheel?
At a more advanced level though, you might want to interact with a site - log in to it perhaps, or 'click through' some menus. For this, I like WWW::Mechanize.
I'm afraid I can't give you much more without a better understanding of the sort of problem you're trying to solve though. Are you at a basic 'fetch a webpage and parse' sort of level?
(You can find details and examples of the above modules on CPAN. The LWP page has some examples that should get you started.)

I wrote a pretty basic tutorial on WWW::Mechanize here
..I have successfully crawled pages on several occasions so please let me know if you have a case you would like to try and need some help :)

To start you can look at WWW::Mechanize and HTML::TreeBuilder::XPath modules.

In my opinion, the best module for web scraping is Web::Scraper. Its language can be quite terse at times, but there are plenty of examples.

Related

Recommend a good mongodb/database tutorial for a beginner? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I'm a designer; proficient at HTML/CSS/JQuery. I know next to nothing about databases. I'm interested in learning mongodb (it seems simpler), but can't find any tutorials that will hold my hand from start to finish. Most tutorials I've found teach you how to use it in the command line or in their own web based shell. I'm looking for something that will show me how to actually deploy a site using it.
Or, if mongodb isn't appropriate for a database novice, then can you recommend some database tutorial that will be good for what I'm looking for?
Here are a couple of great sources that I have checked while docummenting to create a course:
A grasp of classic Relational Databases:
http://net.tutsplus.com/tutorials/tools-and-tips/relational-databases-for-dummies/
And continue with visual creation of Databases:
http://net.tutsplus.com/tutorials/databases/visual-database-creation-with-mysql-workbench/
Next, you can go deeper in SQL knowledge:
http://net.tutsplus.com/tutorials/databases/sql-for-beginners/
http://net.tutsplus.com/tutorials/databases/sql-for-beginners-part-2/
http://net.tutsplus.com/tutorials/databases/sql-for-beginners-part-3-database-relationships/
Now, get to know the non-Relational "NoSQL" world:
http://net.tutsplus.com/tutorials/databases/getting-started-with-mongodb/
http://net.tutsplus.com/tutorials/databases/getting-started-with-mongodb-part-2/
Note: You can go directly to the MongoDB/NoSQL part directly, but I
recommend at least reviewing the first link (Relational Databases) to
get a good knowledge of the pros and cons of both paradigms.
p.s. I'm not part of tutsplus.com nor related to them. IMO, these matters are really well explained there
Most tutorials I've found teach you how to use it in the command line or in their own web based shell. I'm looking for something that will show me how to actually deploy a site using it.
This is basically where MongoDB starts. It's not really at the level of MySQL or SQL Server where you click a few buttons and have everything magically working.
The tutorials will start you at the command-line so that you can do basic CRUD (Create/Read/Update/Delete). Then you'll need to learn the specific details for whatever language you're using on the web-server (PHP, Ruby, C#, etc.)
There are tutorials for getting started (installing MongoDB on your server, installing drivers, etc). But you'll have to let us know what language you're using in the back end.
PHP has a ton of "getting started" documentation.
Here's a good link of links. Here's one of the links with basic wrapper code. And here's a link with an extensive example.
You'll probably find that the PHP code is very similar to the shell. You use array('_id' => 'bob') instead of { _id: 'bob'} and db->coll->find() instead of db.coll.find().

Good commenting practices [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
I just completed with one of my applications which is now ready to be tested. But before submitting my application I want to make sure I have used appropriate comments wherever required. Though I use comments in most of my applications but it is this time I have realized that my application is quite complex and thus for the purpose of reviewing the code again and for functional understanding I need proper commenting. I was also worried about the amount of commenting in my application.
What I am looking for are standard commenting practices we need to follow in IPhone development.
Kindly assist.
Good Comments say "why" you did something, not "what" you did.
I usually implement comments in the following situations, (this is by no means exhaustive), and any developer reviewing or debugging your application would appreciate them in these situations:
When I use a third-party or otherwise obscure library;
In deep-nested control structures when they cannot be avoided;
When implementing my own protocols in Obj-C (when they are not obvious);
And in general when something is not obvious to you and/or a potential reviewer
EDIT: And I also suggest implementing sparingly, if you did not get that from the post. It is annoying to read code that is near the over-commenting threshold. You do not want to feel like you are reading an introduction to programming book.
There is nothing special with regard to comments and iPhone development.
Personally I prefer readable (self-documenting) code over comments. That is, using meaningful method and variable names to make the purpose of the code understood. If it still can't be understood then comments might be useful, but don't make them too long. A problem with long comments is that they might fall out of sync with the sources and become misleading.
I think links to other sources of documentation are good, such as stackoverflow questions, bug databases, etc.
These, to me, are the golden principles:
Comments should never explain code (use self-explanatory code with proper names and indentation).
Don't insult the reader's intelligence with unnesseary comments
Comment by code block (if you need to explain a process, don't use seperate comments on each line of the code block).
When Im commenting my code, I act as if I had some half wit programmer sitting right next to me asking me "what does this code do, and why are you doing it?" Ill reply in a nutshell of an answer.
My response to him is what I comment.
// now that we got the data we need lets store it in the Settings Array
// check for NULL if null, change to None Selected
// make sure there is an object here so we dont crash

Learning... anything really [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I'm particularly interested in Windows PowerShell, but here's a somewhat more general complaint:
When asking for help on learning something new, be it a small subject on PHP or understanding a class in Java, what usually happens is that people direct me towards the documentation pages.
What I'm looking for is somewhat of a course. A deep explanation of why something works the way it does.
I know my basic programming, like Java and C#. I've never seen C or C++, though I have seen a bit of assembler. I know what the Stack and Heap are, how boxing and unboxing works, why you have to deep-copy an array instead of copying the pointer and some other things.
Windows PowerShell on the other hand, I know nothing about. And I notice that when reading the small document or some code, I usually forget what it does or why it works.
What I am looking for is preferably, a nice tutorial that explains the beginnings, the concepts, and goes to more difficult things at a steady pace.
The only thing documentation can do is explain what a function does. That's no good to me since I don't know what I want to do yet. I could read about a thousand functions, and forget about most of them, because I don't need to implement them right after it. Randomly wandering through the documentation doesn't do me any good.
So conclude, what is a good tutorial on Windows Powershell? One which explains in clear language what is happening, one which builds on previous things learned.
I don't think googling this is a good idea. Doing a Google search on this would turn up numerous tutorials. And experience tells me that you have to look long and hard to find the gem you're looking for. That's why I'm asking here. Because this is the place where you can find more experienced people. Many of the PowerShell guys among you will know the good ones already, and by asking you, I avoid wasting time that could be spent learning. So to summarize: I will not google this!
I wrote a free eBook along these lines. I will let you be the judge of whether or not it is good but my goal was to provide folks with a good mental model for how PowerShell works. You can download it from here. It is about 60 pages or so. You can find a more comprehensive free ebook online called Master-PowerShell.
Of course, you can peruse StackOverflow for Q&A and also ask questions as you have them.
I like this one
http://arstechnica.com/business/news/2005/10/msh.ars/2
I wouldn't consider doing research on a programming language a failure, even if it takes you forever to find that "gem" you are looking for. Searching for awesome material is an art and the more you do it, the better you get at it. The community won't always be able (or willing) to answer all of your questions for you, especially if they know you haven't done your due diligence to look something up.
"What tutorial do you recommend for learning PowerShell?" might be an answer to your question.
I like to use the O'Reilly Pocket Reference versions of books to get started in a new subject. Easy to take with you on the plane, on a lunch break, or in the necessary (beats People magazine).
Here's the Windows PowerShell Pocket Reference at Amazon. $6.84 for a Used copy.

Where can I get good answers to my Perl-related questions? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
AFAIK one of the objectives of Stack Overflow is to make sure anyone can come here and find good answers to her Perl related questions. Certainly beginners would ask what is the best online source to learn Perl but others might just want to ask a question.
Probably the friendliest place is the Monastery of Perl Monks. It is a web site with a rating system similar to but more simple than Stack Overflow. You can find lots of good answers there and if you don't find an answer you can always ask.
The other big resource would be the mailing list of your local Perl Mongers group.
Where do you go when you are looking for an answer to a Perl related question?
It's worth noting that http://perlmonks.org, in addition to the fora, has the Chatterbox, where simple questions can be answered immediately in conversation with other users.
It requires setting up an account and logging in before using the Chatterbox, though.
Thus far, I've been pretty content with the quality of Perl answers I've seen here. Many of the most experienced Perl programmers I know from conferences, Perlmonks, use.perl.org, etc. seem to be present here and answering questions seriously and clearly. In cases where an answer has been wrong or simply bad in a sense of promoting bad practice, those answers have been quickly identified, voted down and/or commented-upon.
I'm a great fan of Perlmonks, but it's a different sort of site than this one. Besides being specific to Perl, it also has separate areas set aside for reviewing modules, posting code snippets, reviewing books, etc.
Best place: here. Each time I asked, I got correct answers, in less than 20 minutes. Faster that anywhere else.
I've never asked questions, but that's probably because I tend to write simple scripts rather than applications.
Have always found the Perldoc site to be a good way to work out how to do stuff - and I normally learn a bit more whilst looking.
Sometimes, it might be worthwhile to try to get help via IRC. Quite some time ago, I found the #perl channel on the freenode network to be pretty friendly and helpful. As always it's important that you have exhausted the normal means of solving your problem: Read the documentation, search the web, etc.
However, I'll also take this opportunity to mention where you should not go asking for help: The #perl channel on MagNet aka irc.perl.org. It's a channel where people just hang out and talk about essentially anything but help requests. However, on that network, there's quite a few channels particularly about certain Perl-related projects. The people who lurk in those may well be the primary authors of the relevant piece of software. Those channel's aren't help desks either, but if you have a very challenging and interesting problem, you might be able to get them interested enough to help you. Just make sure you do your homework first and be prepared to get involved yourself.
For documentation on Perl builtins and standard modules, perldoc.perl.org is an web version of the Perl docs with pretty colors and such. I use a keyword bookmark, pd for this.
For finding modules, search.cpan.org is the place to go; for this I use the keyword pm.
When you have a question that requires humans to answer, Perl Monks is my preferred place, though Stack Overflow seems to have attracted a good crowd already.
Usenet is pretty good too
comp.lang.perl.misc, comp.lang.perl.modules and comp.lang.perl.moderated are good places to ask questions IMHO.
The Official Perl 5 Wiki is another great resource with lots of info and links.
(Also see the bottom of the wiki home page for the latest headlines from the Planet Perl feed aggregator. It's useful to look at, because it sometimes suggests questions that you didn't know that you should be asking.)
Incidentally, an ambitious stackoverflow Perl fan could also add a new section to the Perl 5 wiki pointing to questions answered on stackoverflow (and perhaps vice versa).
I favor use.perl.org over perlmonks. I'm not sure why. It's a smaller community, maybe the signal to noise ratio is higher for me.
Incidentally, I get good answers there to any question, not just Perl questions. I ask Java questions, Linux questions, sometimes even cultural questions, and there's always someone there who knows. :)
I am surprised that no one has mentioned the Perl Beginners mailing list.
I like IRC, try #perl on irc.perl.org or irc.freenode.net, or maybe #perlhelp on irc.efnet.nl. Lots and lots of very clever, helpful people always willing to discuss perl-related issues.
Maybe I'll see you there :)
I don't have a specific site, but tend to just google the main keywords of what I am looking for. There are many sites out there, however, I have got the best responses here for very specific stuff.
Have a big AIM/Jabber list filled with knowledgeable Perl people you're friends with.
I talk to my imaginary friends on #catalyst, #perl and other channels on irc.perl.org.
[edit] Bearing in mind that due to the limitations of non face to face communication with people you don't really know, you need to be simultaneously respectful of people whom it might superficially look like are being very rude to you. It pays to be thick skinned on IRC.
I would say Stackoverflow

Developing addins for World of Warcraft - Getting started? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
As a long time World of Warcraft player, and a passionate developer I have decided that I would like to combine the two and set about developing some addins. Not only to improve my gameplay experience but as a great opportunity to learn something new.
Does anyone have any advice on how to go about starting out?
Is there an IDE one can use? How does one go about testing? Are there any ready made libraries available? Or would I get a better learning experience by ignoring the libraries and building from scratch? How do I oneshot Hogger?
Would love to hear your advice, experiences and views.
This article explains how to start pretty well.
Your first bookmark is possibly the US Interface Forum, especially the Stickies for that:
http://us.battle.net/wow/en/forum/1011693/
Then, grab some simple addons to learn how XML and LUA interacts. The WoWWiki HOWTO List is a good point here as well.
One important thing to keep in mind: World of Warcraft is available in many languages. If you have a EU Account, you got an excellent testing bed by simply downloading the language Packs for Spanish, German and French. If you're an US Guy, check if you can get the Latin America version. That way, you can test it against another language version.
Once you made 1 or 2 really small and simple addons just to learn how to use it, have a look at the various frameworks. WowAce is a popular one, but there are others.
Just keep one thing in mind: Making an Addon is work. Maintaining one is even more work. With each new Patch, there may be breaking changes, and the next Addon will surely cause a big Exodus of Addons, just like Patch 2.0.1 did.
Another useful tools you might like is WarcraftAddOnStudio which lets you make plugins in the visual studio environment.
I learned the art of add-ons primarily by looking at the code of Blizzard's UI. You can see that code by extracting the default UI or finding a copy of the default UI online. Add-on developers sometimes like to over-engineer their pet projects (who doesn't?), while Blizzard's code is usually pretty no-nonsense and straightforward. In addition, Programming in Lua is a pretty useful (if slightly out-of-date) reference for the actual Lua language.
The best way to start is with the book World of Warcraft Programming. It covers LUA, XML, WarcraftAddOnStudio and the WoW API. The book also has sections on best practices and avoiding common mistakes.