Posts

Build Your Own Bot to Extract Hidden Meta Tags from Any YouTube Video Pages

YouTube page has hidden meta tags which are not hidden to other webpages. In this code block you will see how to create a python bot which can extract this hidden gem Meta tags. This code is created using Python and Scrapy Framework all together. import scrapy class YoutubeSpider(scrapy.Spider): name = 'youtube' allowed_domains = ['youtube.com'] start_urls = ['https://www.youtube.com/watch?v=afyH2treks0'] def parse(self, response): tag = response.xpath("//meta[@name='keywords']/@content").get() yield { "tag": tag }

How to create new folder/directory in Python / Safely create a nested directory?

There are some situation during our programming life that we need to create folder for different purbpses. Like, if I want to put output information of my program to a folder then I need to ceate a folder or check folder is there or not. If the folder does not exist, then the program should create a new folder with folder name as given in the program. But if it is already there then what to do? We dont need to create the folder. We cad proceed the programming. import os def createFolder(folderName): try: if not os.path.exists(folderName): os.makedirs(folderName) print('folder created successfully!') else: print('folder alreay existed!') except OSError: print('Error - Folder Createion') createFolder('a1') createFolder('a2') That is the code for createing an empty folder. And its a safe programming practices also. If you need to create nested directory, you can just i...

Merge/join two or more video files using Python

Using Pyhton, we can easily add two or more videos files easily. We just need to use the moviepy package. Once we import that package, we can ean use the methods or functions to add movie files. Here, in this tutorial, we joined/merged two video files. But it is not limited to add only two video files. We can add multiple video files using the same program with the change of no of files expressions. Just import all the movie files and then join using the same concept. from moviepy.editor import * # load clips clip_01 = VideoFileClip('nature.mp4') clip_02 = VideoFileClip('rain.mp4') # join + write result_clip = concatenate_videoclips([clip_01, clip_02]) result_clip.write_videofile('combined.mp4') Here, in this program we imported the moviepy package. Later, we loaded two video files. If you want to add multiple video files, just import all of them. Finally, we concatenate by using the method concatenate_videoclips() and we saved it in the directory locat...

Cheatsheet for Effective ways to use XPath in Selenium

XPath in Selenium: XPath is a technique in Selenium to navigate through the HTML structure of a page.  XPath enables testers to navigate through the XML structure of any document, and this can be used on both HTML and XML documents. When to use XPath: while the locators in Selenium are not enough to search elements using tags or CSS class names, then we use XPath to find the elements or to traverse the element Benefits of XPath: XPath provides an option to dynamically search for an element within a web page, thus giving sufficient flexibility to tweak a locator to one’s advantage. Types of XPaths in Selenium: Absolute Path/ single slash search simple but most vulnerable to minor changes in the structure of the page Example: /html/body/form/p[3]/input Relative Path/double slash search begins with double slashes Example: //form/p[3]

Selenium XPath Practice

Practice form for selenium xpath.  First Name Last Name Email Password

Java Memory - Stack VS Heap - Java interview question

Image
Why Java Momory is important:     code optimization     avoiding code errors JVM - complecated learn how memory is managed - java developer task Stack/ Stack Memory: A Stack is a Last In First Out (LIFO) data structure. It supports two basic operations called push and pop/pull. The stack is a very efficient data structure which is managed effectively by the Java virtual machine. One important aspect of the stack is that Java knows exactly when data on the stack can be destroyed. used: are great for local primitive variables (short lifetime) (like int, double)   when do we use?  Every thread has its own stack.  So, data on the stack can only be seen by the thread that owns the stack.  a stack is used helps us understand how variable scope really works.  memory size of a Java stack is generally much less than in a Java heap space because when a method ends, all the variables created on the stack are erased forever. The size of the sta...