General approach for scraping multiple pages separated by 'next' link - web-scraping

Using an in-browser scripting extension like Greasemonkey or Tampermonkey, what's the usual general approach to take when scraping information over multiple pages, where pages are navigated using 'next' links, which reload the top-level document?
I've written something like this in the past where the information I wanted to scrape was in a frame, and the 'next' link reloaded just the frame, which was nice and easy. But I now have an instance where the 'next' link reloads the whole page, which of course causes the user script to reload too, forgetting where it was :)
I imagine I could get this to work by loading the content into a frame which I insert into the page (and then generate clicks within that frame), but if there's a more elegant solution I'd like to hear it!

Related

How to make form like example

there is this site https://www.delinski.at/ and it has a nice form where you can pick some values from dropdowns like Date, Number of Persons etc., and then submit the form. It redirects and I see the values on the redirected page link as parameters (if I have changed the defaults).
I searched for and tried several Form Plugins which all do not seem to work - most recent one (Form Maker) lets me design the form as I want but at the end I realized when I click on Submit, the values are not transfered to the target page (confirmed by Form Maker Support as work as intended). It's confusing because actually that should be a basic funciontality of a HTML form, right?
So I want to know if there are plugins where I can get a similar look&feel like the example given above.
That site is a Static Site Generated framework not WordPress. That site would also be very expensive to build cause that is all coded, and very well:)
You are not actually seeing a form there at all that is just how PHP natively uses the URL to navigate via a button.
Almost all the form plug ins for WP use the database write now and do not pass the parameters of the entered form as a php _ POST with a redirect.
I kind of think what you really are looking for is a faceted search feature
One of the best that comes to my mind is https://facetwp.com/demo/cars/?_vehicle_type=truck
Notice the car icons those are actually search buttons:) Of course you will have to build a template to do that neat stuff on the SSG site you linked but...
here is a really informative write upon how it works to get started.

Extracting content data from webpages

I'm looking to get structured article data from webpage urls. So far I've found these two services http://www.diffbot.com/ and http://embed.ly/extract/demos/nlp. Are there better alternatives or is it worthwhile to write the code to do this myself?
If you'd like to skip the code, and are looking for a simple software for web scraping / ETL applications, I'd suggest Foxtrot. It's easy enough to use and doesn't require coding. I use it to scrape data from certain gov't websites and dump it into an Excel spreadsheet for reporting purposes.
I have done web scraping / content extract for quite some time now.
For me the best approach is to write a Chrome content extension and automate the browser with their API. This requires that you know Javascript and HTML. In one of my recent projects I use a background page with a couple of editable divs to configure the scraping session. I have some buttons on the background page to start the process. The background page loads a JS script which listens to click events of the buttons.
When one of the buttons is clicked I add a new tab for the scraping session with chrome.tab.create. The background js also defines some chrome.tabs.onUpdated.addListener to inject content scripts when the tab url contains a specific page/domain name.
The content script then does the scraping job for example selecting some elements with jquery, regular expressions etc and finally send a message with an object back to background JS using chrome.runtime.sendmessage. The background JS script listens to messages with chrome.runtime.onMessage.addListener and acts based on the content being extracted.
The extension also automates web databases by clicking for example the next page links.
I have added a timing setting to control the amount of links being clicked / tabs being opened per minute so that the access is slowed down on purpose and too much crawling is avoided.
Finally the results are being uploaded to a database with an AJAX call and inserted with a PHP page into MySQL.
When the extension runs the next time it compares the keys/links which already exist in the database with another AJAX call and ensures that only new information is being extracted.
I have also built extension like the above with Firefox but the best and easiest solution for me is a Chrome/Chromium content extension.

Progressive page loading in ASP.NET MV3?

I'm building a website that on its frontpage has different 'lists' of stories/articles.
You can compare it to Wordpress 'latest articles', 'spotlight articles' etc.
Now every list needs to be created, and filled from the repository.
Which means, that in my controller, I first create/retrieve all the lists, add them to the ViewBag, and then return the view.
In the View i'll then foreach over the items in that list to create a visual list to be shown on the frontpage.
However, when I load the page, I first get a blank page, when the page is loaded, and then at one point everything appears.
Traditionally, you would already see the basic html, text etc, and then the dynamic area's would appear later.
Is it possible to have a similar 'progressive loading' with MVC3?
Its not so much the performance I'm worrying about but more so the user experience of seeing a blank page for several seconds on data-heavy pages.
Thanks :)
If you've got heavy pages with long loading times you might consider loading the pieces more dynamically using an ajax approach.
Your page loads, you execute the requests for the data you require and use some standard loading icon in the meantime.

VB.Net application - display a message to the user whilst the application is starting up

I have recently created an application where a lot of data is loaded into objects when the application starts up, and other data as it is required. For example if the user requests the catalogue page then it will load all the top level category data into objects of type Category. This will then stay there to be used by other users (who will therefore not have to load this data into objects) and can be altered by admin if they happen to login during the same application instance. I know this is not the most efficient solution, as pointed out below, but it works and the page load, at the moment, is not too long. It is very quick if most of the required data is already loaded into objects. It is also tailored to the business' needs - unlike other techniques such as Linq-to-SQL.
The problem I am facing is when a page is requested which requires lots of data to be displayed about different types of object. For example when a catalogue page is requested which displays information on a product which can be bought, it then loads all the products and categories (as the products make reference to the category object, not just the category name).
I would like to display a loading symbol with a message whilst all this data is being loaded into objects, so the user knows its not just in a loop or anything. Is there any way to do this? I am open to using JS / jQuery if I need to.
Thanks in advance.
Regards,
Richard
PS I am working on ways to make it more efficient - such as using HashTables or HashMaps. However this is taking time as there are so many different types of item (News, Events, Catalogue Item - Range, Collection, Design, RangeCollection, CollectionDesign, RangeCollectionDesign and RangeDesign - Users, PageViews and the list goes on).
Please correct me if I'm wrong, but I do believe that Javascript is required in order to display a "loading" image... Using server-side scriping alone would typically require an entire page load after all the content loads unless you want to start messing with IFrames.
This is a job for AJAX. A common solution to your problem is to have a small page that displays a loading icon. The page has some JavaScript that makes additional HTTP requests to the server to download the rest of the page. JQuery has a "$.ajax" method that is designed to simplify this process.
I would suggest looking at the documentation to the .ajax method in the jQuery documentation. Unfortunately, it seems to be a rather delicate process to get all the scripting code right and it takes a while to learn it all.

Detecting and closing frames using Javascript

I'm working on an ASP.NET web application. There's a bill page which has two links to different pdfs of the same bill. When you click on one of the links it takes you to a ViewPDF.aspx page that shows the pdf. There's also an option to view both in a split screen so that you can compare them. When you click on this link it takes you to BillSplit.aspx which has a frameset and two frames that both point to ViewPDF.aspx. This all works perfectly.
The problem is that if an error occurs while pulling up the pdf. The application has an error page that has a few links back into the application. If you use one of these you can go back into the app and continue but now inside the frame. The URL still says BillSplit.aspx but the application is completely unaware of this since frames are HTML elements not asp.net controls.
What I would like to do at this point is detect that you've returned to the application and close the frame you aren't using. Essentially I'd like to redirect you away from BillSplit.aspx and to the page you're actually requesting. I'm pretty sure this would need to be done in Javascript either on the BillSplit page or on the pages that you go to later.
So I guess what I'm asking is, is there a way to ensure that the BillSplit.aspx page and it's two frames point only at ViewPDF.aspx? Thanks!
if both the page and the frames inside the frames are on the same domain.
you can maybe register a startup script when you get to the error page.
what the script will do is something like checking if he is inside a frame
with something like with the top.document anyway if it does you can then
redirect in the client to another page you want.
or even to the error page.
this way it wont display inside frames.
will that help?

Resources