Posts

sample code to retrieve webpage contents using selenium

Image
Selenium webdriver is primarily it is for automating web applications for testing purposes, but has also gained popularity to scrape content from dynamic webpages that contain javascript and retrieve content on the fly when the webpage is loaded. Such webpages cannot be scraped using native solutions in most programming languages, since the query and the result take place when an action is performed is difficult to mimic in the out of the box solutions. There is where Selemium comes in handy and helps fire the action that initiates the query and captures the response when it comes through. An example of this can be found in the current blogpost, where we will see the behaviour of a popular webpage that loads content on the fly, and how selenium webdriver can be used to extract the information we need. Let's say that one needs to extract the results of the matches and match links for all matches in the 1999/00 season from the Premier League website, the link to which is here . The

pandas dataframe - how to extract the number of instances of each unique value

If the number of instances of a value that occurs multiple times is in a dataframe, is to be determined, the syntax to be used is as follows: df[column_name].value_counts() There are more uses of this function that can be found here .

convert datetime to string in python

strftime is an instance method of the datetime class in python and is used to convert datetime objects to an explicit form of string [1] . Examples of such usages are as follows: Convert datetime object to yyyy-mm-dd string type. relevant_match.strftime("%Y-%m-%d") Details of different string types can be found here .