Another Code School Profile Scraper Update

CodeSchool logo

Merry Christmas!

This will be a short post – I guess Code School must make minor changes to their user profile code about this time each year, as it was just a year ago that I had to update this code.

For the codeschool.php file, change this:

/* disabling the anchor tags on each badge by changing to divs */
$full_content = str_replace("<a href","<div class",$full_content);
$full_content = str_replace("</a>","</div>",$full_content);

to this:

/* disabling the anchor tags on each badge by changing to divs */
$full_content = str_replace("<a rel=\"tooltip\" ","<div ",$full_content);
$full_content = str_replace("href=\"/learn","data-href=\"http://codeschool.com/learn",$full_content);
$full_content = str_replace("</a>","</div>",$full_content);

This will eliminate the links that would be intended to point at the Code School paths, but instead end up being broken links pointing at your own site.

Have a Happy New Year!

Dealing with the Mixed Content Over HTTPS Error

Google Chrome logo

It’s a new year, and with it comes new resolve to keep current with modern web development technologies! I had begun working through the recently-added PHP Path on Code School, and almost immediately I ran into a problem wherein the submit button on a quiz page caused the page to quit working.

I reloaded the page and opened Chrome DevTools with F12 to see if any errors could be seen there. Sure enough, a couple of Mixed Content errors appeared when I tried to submit an answer again:

Mixed Content error in Chrome

I figured at first that there must be something wrong on the Code School web server. Because, of course the problem’s not on our side, right?! It then occurred to me that I run the HTTPS Everywhere extension (which I highly recommend, by the way) in Chrome. I decided to turn it off while using the Code School site to see if that would resolve the issue.

Success!

That fixed the problem! The moral of this story is that while problems with HTTPS certs or web server settings could cause this error, check first to see if HTTPS Everywhere is the source of your troubles.

Nota bene: This fix could apply not only to Chrome, but to any browser that can run this extension.

End of Another Year! … and a Minor Update to the Code School Profile Scraper

CodeSchool logo

It’s hard to believe 2016 is already drawing to a close. It seems like just yesterday that I was writing about using PHP to search through my source code!

Though I wouldn’t call this an intractable problem, I did notice something annoying when looking at my Code School profile on the sidebar of this site.

Code School Profile with LI Bullet

Between the badges in the “Master Status” section, white dots had appeared! Upon inspecting these, I saw that these were the bullets on the list items that held the badges.

One article on Stack Overflow suggested that the CSS style for the tag for the unordered list that holds the list items should be include “list-style-type: none;”, but that seemed to have no effect.

After playing with the CSS a bit, I discovered that setting that property on the li tag instead fixed the problem.

Here is the corrected CSS code which updates the code from a past post:

<style>
#codeschool {
   border: 1px solid blue;
   text-align: center;
   vertical-align: middle;
}

#codeschool li {
   list-style-type: none;
}

.badge-img {
   display:block !important;
   margin-left: auto;
   margin-right: auto;
}

.pr-avatar {
   display:block;
   margin-left: auto;
   margin-right: auto;
   margin-bottom: 10px;
}
</style>

By implementing this minor change, the bullets disappeared, and the profile looks as it did originally.

Have a Merry Christmas and a Happy New Year!