There is an immense amount to be learned simply by tinkering with things. - Henry Ford
In this new blog code challenge you are going to use
selenium to automatically generate some cool featured images for PyBites. Let's write some Python code, shall we?
Some time ago Bob made a tool to automate blog image generation: Featured Image Creator.
In this challenge you will help PyBites create some nice featured images for their code challenges or articles (heck, we could even use them on Twitter!)
Make a virtual env and pip install
selenium (and optionally
feedparser), however this is not a requirement, use your favorite tools ...
Using Selenium navigate to Featured Image Creator and set the canvas (button ID
#submitDimensions) to your preferred size (e.g. w=300/ h=100, or w=200 / h=200)
Loop over the challenge and/or article titles you scraped and for each title:
enter the title alongside Title text in image (blog post) (
#title ID field).
choose a Margin-top and Google Font from the two dropdown fields (
#font field IDs respectively).
choose a theme: BG theme: material or BG theme: bamboo (
#collection ID field).
choose a picture from the auto-complete (
#bg1_url ID field), or just fill in the field picking random ones from the 2 lists below (one per theme):
featured_image/images/material]# ls -C1|grep full|sort|sed '[email protected]\(.*\)@images/material/\[email protected]' images/material/black-blue_full.jpg images/material/black_full.jpg images/material/black-red_full.jpg images/material/blue-black_full.jpg images/material/blue-brown_full.png images/material/blue_full.jpg images/material/blue-green_full.png images/material/blue-lightblue-white_full.jpg images/material/blue-white_full.jpg images/material/blue-yellow_full.png images/material/darkgreen-red-yellow_full.png images/material/green-blue_full.jpg images/material/green_full.png images/material/green-red_full.jpg images/material/orange-black_full.jpg images/material/orange-blue_full.jpg images/material/purple-blue_full.jpg images/material/purple-blue-red_full.jpg images/material/purple-red-orange_full.png images/material/purple-red-white_full.png images/material/purple-yellow-white_full.png images/material/red_full.jpg images/material/red-green_full.jpg images/material/white-blue_full.png images/material/yellow-darkgrey-red_full.jpg featured_image/images/bamboo]# ls -C1|grep full|sort -n|sed '[email protected]\(.*\)@images/bamboo/\[email protected]' images/bamboo/1_green_full.jpg images/bamboo/2_black_full.jpg images/bamboo/3_black_full.jpg images/bamboo/4_black_full.jpg images/bamboo/5_black_full.jpg images/bamboo/6_white_black_full.jpg images/bamboo/7_black_full.jpg images/bamboo/8_black_full.jpg images/bamboo/9_black_full.jpg images/bamboo/10_green_full.jpg images/bamboo/11_black_full.jpg images/bamboo/12_black_olive_full.jpg images/bamboo/13_gray_full.jpg images/bamboo/14_black_full.jpg images/bamboo/15_green_full.jpg images/bamboo/16_black_full.jpg images/bamboo/17_green_white_olive_full.jpg images/bamboo/18_black_full.jpg images/bamboo/19_green_full.jpg images/bamboo/20_gray_full.jpg images/bamboo/21_silver_full.jpg images/bamboo/22_white_full.jpg images/bamboo/23_black_olive_full.jpg images/bamboo/24_white_full.jpg images/bamboo/25_black_white_full.jpg
Feel free to set the other fields as well, but so far your should have a decent featured image, so move onto to saving the image ...
Click the Save button (
#btnSave ID field).
Move the obtained file to an output directory and zip them up (using Python's
PR your work on our platform including the generated zipfile (or host it yourself and link in the PR to keep our challenges repo lean).
Good luck and have fun coding Python! Ideas for future challenges? use GH Issues.
At PyBites we're all about creating Python ninjas through challenges and real-world exercises. Read more about our story.
We are happy and proud to share that we now hear monthly stories from our users that they're landing new Python jobs. For many this is a dream come true, especially as they're often landing roles with significantly higher salaries!
Our 200 Bites of Py exercises are geared toward instilling the habit of coding frequently, if not daily which will dramatically improve your Python and problem solving skills. This is THE number one skillset necessary to becoming a linchpin in the industry and will enable you to crush it wherever codes need to be written.
Take our free trial and let us know on Slack how it helps you improve your Python!
>>> from pybites import Bob, Julian Keep Calm and Code in Python!
Do you want to get 250+ concise and applicable Python tips in an ebook that will cost you less than 10 bucks (future updates included), check it out here.
"The discussions are succinct yet thorough enough to give you a solid grasp of the particular problem. I just wish I would have had this book when I started learning Python." - Daniel H
"Bob and Julian are the masters at aggregating these small snippets of code that can really make certain aspects of coding easier." - Jesse B
"This is now my favourite first Python go-to reference." - Anthony L
"Do you ever go on one of those cooking websites for a recipe and have to scroll for what feels like an eternity to get to the ingredients and the 4 steps the recipe actually takes? This is the opposite of that." - Sergio S