scrape from web page into html - screen-scraping

I will ask you a rather simple question (probably).
I would like to scrape a web page, namely:
http://www.carmudi.com.bd/mitsubishi-lancer-ex-12877-43.html?s_category=29&s_q=se129ca11xgiintcarmx&s_dir=desc&s_no_result_page=1&disable_previous=true
i would like to extract the informations shown into the box on the right
(containing price, accident ... and all those subparamenters)
and push them into a simple Html template.
Into the html, I would like to show a table containing the image and then a bullet point with, for example,
price
condition
What is the easiest way to do that?
Thank you so much for the help.
cheers,
Vincenzo

You may implement this using two methods:
Converting the required data to XML and then parse the data
Use Yahoo Query Language or YQL to parse the html to xml, ex:
http://query.yahooapis.com/v1/public/yql?q=select * from html where url="http://stackoverflow.com" and xpath='//div/h3/a'
The Xpath you need would be :
//*[#id="detail"]/div[1]/article/section[1]/div[2]/div[2]/table/tbody
Use DOM structure to access each data via javscript
var myDataTable = document.getElementById('detail').div[1].article.section[1].div[2].div[2].table;
Later use Element.innerHTML property to access data.

Related

How to prevent hard-coding in angular application

I am currently working on a angular project where I find myself injecting hard-coded values of string, numbers, etc into html template.I have tried to store hard-coded values in object fields and inject the object into whichever component needs it. However it does not seem very intuitive. Is there way to get values from some properties file like we do in Java. I would also like to know what are some of the best practices that you developers are using to prevent that?
You can do it with a properties file as well. The best way would be to create a json file, e.g., example.json and calling in the json and then just making an API call like:
$http.get('your_web_address/example.json')
.success(function(data){
// assign the data to a var or write next logic directly
})
and then use the content of json as per choice
You can make this as a service call as well, if you want

SuiteCommerce Advanced - Show a custom record on the PDP

I am looking to create a feature whereby a User can download any available documents related to the item from a tab on the PDP.
So far I have created a custom record called Documentation (customrecord_documentation) containing the following fields:
Related item : custrecord_documentation_related_item
Type : custrecord_documentation_type
Document : custrecord_documentation_document
Description : custrecord_documentation_description
Related Item ID : custrecord_documentation_related_item_id
The functionality works fine on the backend of NetSuite where I can assign documents to an Inventory item. The stumbling block is trying to fetch the data to the front end of the SCA webstore.
Any help on the above would be much appreciated.
I've come at this a number of ways.
One way is to create a Suitelet that returns JSON of the document names and urls. The urls can be the real Netsuite urls or they can be the urls of your suitelet where you set up the suitelet to return the doc when accessed with action=doc&id=_docid_ query params.
Add a target <div id="relatedDocs"></div> to the item_details.tpl
In your ItemDetailsView's init_Plugins add
$.getJSON('app/site/hosting/scriptlet.nl...?action=availabledoc').
then(function(data){
var asHtml = format(data); //however you like
$("#relatedDocs").html(asHtml);
});
You can also go the whole module route. If you created a third party module DocsView then you would add DocsView as a child view to ItemDetailsView.
That's a little more involved so try the option above first to see if it fits your needs. The nice thing is you can just about ignore Backbone with this approach. You can make this a little more portable by using a service.ss instead of the suitelet. You can create your own ssp app for the function so you don't have to deal with SCAs url structure.
It's been a while, but you should be able to access the JSON data from within the related Backbone View class. From there, within the return context, output the value you're wanting to the PDP. Hopefully you're extending the original class and not overwriting / altering the core code :P.
The model associated with the PDP should hold all the JSON data you're looking for. Model.get('...') sort of syntax.
I'd recommend against Suitelets for this, as that's extra execution time, and is a bit slower.
I'm sure you know, but you need to set the documents to be available as public as well.
Hope this helps, thanks.

Ionic search bar

I've 3 jsons files linked with 3 controllers, and I need to search on them using ionic/angularjs. I would like the results appear as dropdown menu, like Facebook search or like here in Stackoverflow.
Thank you.
So there are two things here that you want to do:
Be able to search inside JSON file, I think you can do that, there is a SO thread for same : Angular Search for value in JSON and display corresponding data
Display an Auto-complete drop-down, I think there bunch of directives out there, like: https://www.versioneye.com/javascript/sn0opr:ionic-autocomplete/0.1
You can also check following Ionic forum thread for type ahead recommendation:
https://forum.ionicframework.com/t/recomendation-for-a-typeahead-widget/55
If you want to create your own have look at following tutorial:
http://www.sitepoint.com/creating-a-typeahead-widget-with-angularjs/

Manipulating Soundcloud Stream with Chrome Extension Content Script

I am writing a Chrome extension using AngularJS to add functionality to the Soundcloud stream page. I want to allow the user to create groups of artists so that they may only see a stream with tracks/shares/playlists from that group of artists.
For example, I follow 500 artists, but I want to quickly see a stream from my favorite 10 artists or from the artists I follow that are on the same label.
I am looking for advice on how I could go about making this as seamless as possible. As of right now, my approach involves getting the tracks with the Soundcloud API and using angular's ng-repeat to display the tracks in a view injected into where the stream normally goes. I realized using the Soundcloud widget was too slow and can't be customized to resemble the native stream items, so I copy/pasted the HTML that an actual stream item uses, but obviously the waveform/comment canvas and button functionality don't work.
What are my options as far as how I can approach this? Am I going to need to write my own players that look like the native Soundcloud ones? Any suggestions would be greatly appreciated.
You should use the SoundCloud API which is very well documented.
If you have already the id's of the tracks / artist, you just have to request the url
GET
http://api.soundcloud.com/tracks/ID_OF_TRACK.json?client_id=YOUR_CLIENT_ID
to get all the informations you need about this track, like the waveform_url, and for the comments you was talking about :
GET
http://api.soundcloud.com/tracks/ID_OF_TRACK/comments.json?client_id=YOUR_CLIENT_ID
To reproduce the behaviour of the comments :
POST http://api.soundcloud.com/tracks/ID_OF_TRACK/comments.json?client_id=YOUR_CLIENT_ID
(with a body param which represents the text and a timestamp in ms since the beginnin of the song, note that you must be connected)
If you don't have the id of the track, you could also use the resolve which give you all the info about a ressource if you have only the URL :
GET
http://api.soundcloud.com/resolve.json?url=https://soundcloud.com/poldoore/pete-rock-c-l-smooth-they&client_id=YOUR_CLIENT_ID

Pyrocms Getting Values at front end

I am new to pyrocms.
How can I get database values on pages of pyrocms. In website of pyrocms I had created a listing page now I want to display database values from pyro database table.
I got your question, you want to create a listing on your front-end page for some database table values which you want to access through your custom module controller. there are many ways to get these values but the simplest way is to use ajax. you already have Jquery added in pyrocms so you can simply make a call to your controller method in ajax and get your required output as HTML and display it in the div element on your page.
$.ajax({
type:"POST",
url:"admin/your-controller-name/your-method-name",
success:function(html){
$('yourdiv').html(html);
}
})
In your controller create a method which get data from database and print it using echo create some listing table etc what you want.
i think you will get my point. if confuse then get back to me
You need to be more specific as PyroCMS has lots of components and each module (blogs, variables, widgets, file uploads etc.) uses specific tags you insert into the page. You may come across references to 'Lex' - that's the name of the parser used to display them.
Tags documentation
PyroCMS (the Professional edition) also has a feature called "Streams" which allows you to build custom databases and this in turn has it's own series of tags.

Resources