Apr 21, 2016 Seems to be working as intended. Now let's clean this up a little bit more, because this is still a little messy we want it to only pull ONE url for now and that URL needs to be the actual POST url instead of pulling 3 of the post url and 2 random urls from the same block. Let's go head and switch up the foreach once again. PHP: foreach($html->find('.song-title a') as $element) And now it should return something that looks visually similar to this.
Apr 21, 2016 Now that we have the URL which we will be processing content from in question we can begin working on getting the TITLE portion and the Download portion of that block which was displayed in the first image shown above. (The reason we didn't use it when it was all being printed out is because we wouldn't be able to manage that properly with a messy looking array like that we want it clean so we can easy send certain strings to certain tables in our database.) Let's start off by pulling the image, you can do this with a good 90% of modern websites just by using a simple meta get in the simple_html_dom function list view here to see. PHP: $image = $html2->find('meta[property=og:image]',0);print $image = $image->content; After adding this to our code we can refresh our example page and see that we're now pulling the images + the url for every single song.
Apr 21, 2016 Now our goal is to get the title and believe it or not this is the part I normally have the hardest time with especially on websites in the music niche. A lot of them will explode the title after the ( - ) which makes getting the title almost impossible my website does it also so I am going to show you an alternate way of doing it if a website explodes their titles and you wanna obtain both portions without a messy cluster f--- of code. PHP: print '<br>'; $artist = $html2->find('.content-single .top-head .page-title',0); print $artist = $artist->plaintext; Pull the part of the code which is the ARTIST using the same method we used before when finding an a element this time for a title (You can use inspect element to find the css elements properly.) The code above will display the artist from our website not the song title to display the song title we need to pull the alternate version (The exploded) title with-out the artist. PHP: $song = $html2->find('.content-single .top-head .green',0); print $song = $song->plaintext; Sorry if I am a little slow I am multi-tasking also.
Apr 21, 2016 Gavin, did you have a hard time learning PHP? Did you teach it yourself or in a university? PHP will be one of the upcoming languages which I'll learn. I'm trying to find out how much time I'll need until I can do basic website stuff (in addition to HTML/CSS/jQuery).
Apr 21, 2016 The two portions above return something that looks like this on our array. You can see that it has the Song Artist, and the Song title now being displayed and you only used 4 lines of code. Now is the time to get the download portion and for sites where you wanna have your own custom embed player (I do this for every site) this si where it gets a little fun. Dopefile allows direct streaming from MP3's but in most cases you have to explode the download button to get the ID out of the file so let's do that really quickly here. PHP: $download = $html2->find('.track-buttons-container a',0); print $download = $download ->href; This code above will return the download link for every file (Not the ID). So we will go head and add this code into the mix PHP: $str = explode ("/", $download); print '<br>'; print $str[3]; And this should make it return the following
Apr 21, 2016 Honestly, the scraping process now is done. I guess if interested I could feed it to a database and pull it out through a custom CMS and you guys can see how ti populates content but quite literally I completely everything to automate a website for ever in about 10 minutes just then.
Apr 21, 2016 Respect, same here. How long did it take you to learn PHO until you reached a good level regard webdesign (it's hard to define what a good level is tho).
Apr 21, 2016 I mean, about a year I guess. I started gutting the PHPSound platform and I learned HTML, CSS, Ajax, PHP and pretty much every other web based language from that platform 8leaks is actually based OFF that platform but converted to a WordPress standpoint and after I learned the basics of those languages everything else was pretty much cake walk.
Apr 21, 2016 Scraping websites is such a powerful tool, if you used it properly.. it could be a game changer for sure.
Apr 21, 2016 What you are doing is already changing the game. I'm wondering why other big websites don't use it yet... are they behind the trend? afraid of automated processes (losing jobs)? too dumb to code (probably not)? afraid of legal consquences? I'll feature your thread now, your tips and tricks are as gold as the SXN80 theme right now.
Apr 21, 2016 I think a lot more websites then you know are doing this and a lot of them are using a more simplisticated less advanced method through RSS feeds (This has been around for a very long time) But with PHP you have the ability to control everything and WHO doesn't want that? I am open to post a complete documentation tomorrow about scraping and processing and will even throw out a little bit of a login / mysql storage + echoing out the logged in users name by checking their cookies tomorrow for @Loyalty and I will explain every step of the way how I coded it so the learning process is made a bit easier. IT won't be as scattered as this thread was because I am extremely tired atm been up for 21 hours but I will for sure get to it tomorrow. Salute hope you guys have a blessed after-noon, night, day what ever it may be where you're located.
Apr 21, 2016 Thanks for posting this stuff, it's interesting to know. I will probably reach out if I have questions, barely getting started with the basics of php/mysql, etc. Also interested in learning about JSON. but then there is also a lot of js libraries that jobs around here are looking for.. angular, node, react. Not sure where to start, too much new stuff happening
Apr 21, 2016 I know all of those, so if you have any questions. Literally I am just an inbox message away and I will help you ASAP!
Apr 21, 2016 Appreciate it! I'm sure I'll be messaging you soon. lately I've been paying people on Fiverr to just do stuff I don't know how to do
Apr 21, 2016 Yea, we're not doing that anymore. We're going to work on making sure you learn. You don't learn by having Muhammed the Fiverr working Arabian prince do the work FOR you!