Description:
This function will decrypt the following text by converting a charater to unicode, adding two to the unicode number then convering that number back to a character.
Prerequisites
None.
Input:
The text you want to decrypt
Output:
Decrypted text in string format
Code:
1 2 3 4 5 6 7 8 9 10
def decryptString(oldstring): newstring = '' for letter in oldstring: if letter == ' ': newstring = newstring + ' ' else: newstring = newstring + chr(ord(letter) + 2) return newstring
The function shows how to pass many arguments in to a functon, this is achieved using a list
List of all the values we want to pass
Result of our function
1 2 3 4 5 6 7 8 9
def func(arg1, arg2, arg3): print(arg1) print(arg2) print(arg3) l = ['one', 'two', 'three'] func(*l)
Function to find common items in two lists
none
Two list of objects
Prints a list of the objects that appear in both list
1 2 3 4 5
def sameitems(a,b): set_a = set(a) set_b = set(b) output = [itemA for itemA in set_a if any(itemA in itemB for itemB in set_b)] return output
Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
a = ["apple", "banana", "pear", "apple"] b = ["apple"] def sameitems(a,b): set_a = set(a) set_b = set(b) output = [itemA for itemA in set_a if any(itemA in itemB for itemB in set_b)] return output print(sameitems(a,b))
Will output a list with apple inside
Creates a folder if it does not exist in the specified directory
import os
The directory of where you want to create a folder
1 2 3 4 5 6
def createFolder(directory): try: if not os.path.exists(directory): os.makedirs(directory) except OSError: print ('Error: Creating directory. ' + directory)
import os def createFolder(directory): try: if not os.path.exists(directory): os.makedirs(directory) except OSError: print ('Error: Creating directory. ' + directory) createFolder('C:/Users/myaccount/Documents/newfoldercreated')
A new folder will be created in my documents directory called "newfoldercreated"
Usidng hashlib digest and hashlib hex digest on a list of numbers
import hashlib
A list of numbers
Prints out a hash value. NOTHING IS RETURNED
def usehash(lst): file_hash = hashlib.sha256() for number in lst: file_hash.update(b'%s' %(str(number)).encode('utf-8')) print(file_hash.digest()) print (file_hash.hexdigest(),"\n")
import hashlib lst = [1,2,3,4] def usehash(lst): file_hash = hashlib.sha256() for number in lst: file_hash.update(b'%s' %(str(number)).encode('utf-8')) print(file_hash.digest()) print (file_hash.hexdigest(),"\n") usehash(lst)
Will produce a hash value using the numbers 1,2 and 3. To check if we have the same hash value we can use the following code:
Connect to an existing database file
import sqlite3
from sqlite3 import Error
a .db file in directory
Name of the .db file as a string
will print connected in terminal if python finds the file. The function will then return the connection object so that it can be used later. If Python does not find the file an error is thrown.
1 2 3 4 5 6 7 8
def create_connection(db_file): conn = None try: conn = sqlite3.connect(db_file) print('connected') return conn except Error as e: print(e)
1 2 3 4 5 6 7 8 9 10 11 12 13
import sqlite3 from sqlite3 import Error def create_connection(db_file): conn = None try: conn = sqlite3.connect(db_file) print('connected') return conn except Error as e: print(e) conn = create_connection("mydatabase.db")
Will output connected in terminal
----------------------------------------------------
To create a table:
conn = create_connection("mydatabase.db") cur = conn.cursor() task = ''' -- projects table CREATE TABLE IF NOT EXISTS projects ( id integer PRIMARY KEY, name text NOT NULL, begin_date text, end_date text ); ''' cur.executescript(task)
Function will insert values into the projects table
.db file must have a table created (in this case a table called projects)
A connection to the .db file use create_connection function
Two inputs:
A connection to the .db file
The values you want to pass into the database, these values must be enclosed in brackets and be seperated by commas
The .db file will have a new row with data added
Will return the id of the last row as an integer
def create_project(conn, project): sql = ''' INSERT INTO projects(name,begin_date,end_date) VALUES(?,?,?) ''' cur = conn.cursor() cur.execute(sql, project) return cur.lastrowid
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
import sqlite3 from sqlite3 import Error def create_connection(db_file): conn = None try: conn = sqlite3.connect(db_file) print('connected') return conn except Error as e: print(e) def create_project(conn, project): sql = ''' INSERT INTO projects(name,begin_date,end_date) VALUES(?,?,?) ''' cur = conn.cursor() cur.execute(sql, project) return cur.lastrowid conn = create_connection("mydatabase.db") cur = conn.cursor() task = ''' -- projects table CREATE TABLE IF NOT EXISTS projects ( id integer PRIMARY KEY, name text NOT NULL, begin_date text, end_date text ); ''' cur.executescript(task) project = ('Cool App with SQLite & Python', '2015-01-01', '2015-01-30') project_id = create_project(conn,project)
For editing:
Edit the name of the table and what the table colums are
Function will update values into the projects table
The values you want to pass into the database, these values must be enclosed in brackets and be seperated by commas, The last value must be the row id
The .db file will update the row specified
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
def update_task(conn, task): """ update priority, begin_date, and end date of a task :param conn: :param task: :return: project id """ sql = ''' UPDATE tasks SET priority = ? , begin_date = ? , end_date = ? WHERE id = ?''' cur = conn.cursor() cur.execute(sql, task) conn.commit() return cur.lastrowid
Function will print all existing rows in sql table
Will show all rows in terminal. NOTHING IS RETURNED
def select_all_tasks(conn): cur = conn.cursor() cur.execute("SELECT * FROM tasks") rows = cur.fetchall() for row in rows: print(row)
Opens the chrome browser allowing to search a term on google. The browser will then wait for 60 seconds to prove it is working before it is closed.
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
import time
What you want to search for as a string
google open with input in search box
1 2 3 4 5 6 7
def launchBrowser(search): wd = webdriver.Chrome(ChromeDriverManager().install()) wd.get('https://google.com') search_box = wd.find_element_by_css_selector('input.gLFyf') search_box.send_keys(search) time.sleep(60) return wd
from selenium import webdriver from webdriver_manager.chrome import ChromeDriverManager import time def launchBrowser(search): wd = webdriver.Chrome(ChromeDriverManager().install()) wd.get('https://google.com') search_box = wd.find_element_by_css_selector('input.gLFyf') search_box.send_keys(search) time.sleep(60) return wd driver = launchBrowser('Dogs')
Will open chrome browser, then open google.com followed by adding dog in the search box
get image urls from google images
Three mandantory inputs; Query(What type of images you want), Number of links you want to grab, webdriver
One optional input: How long you want the program to wait before getting the next link
set with number of image link requested
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
def fetch_image_urls(query:str, max_links_to_fetch:int, wd:webdriver, sleep_between_interactions:int=1): def scroll_to_end(wd): wd.execute_script("window.scrollTo(0, document.body.scrollHeight);") time.sleep(sleep_between_interactions) # build the google query search_url = "https://www.google.com/search?safe=off&site=&tbm=isch&source=hp&q={q}&oq={q}&gs_l=img" # load the page wd.get(search_url.format(q=query)) image_urls = set() image_count = 0 results_start = 0 while image_count < max_links_to_fetch: scroll_to_end(wd) # get all image thumbnail results thumbnail_results = wd.find_elements_by_css_selector("img.Q4LuWd") number_results = len(thumbnail_results) print(f"Found: {number_results} search results. Extracting links from {results_start}:{number_results}") for img in thumbnail_results[results_start:number_results]: # try to click every thumbnail such that we can get the real image behind it try: img.click() time.sleep(sleep_between_interactions) except Exception: continue # extract image urls actual_images = wd.find_elements_by_css_selector('img.n3VNCb') for actual_image in actual_images: if actual_image.get_attribute('src') and 'http' in actual_image.get_attribute('src'): image_urls.add(actual_image.get_attribute('src')) image_count = len(image_urls) if len(image_urls) >= max_links_to_fetch: print(f"Found: {len(image_urls)} image links, done!") break else: print("Found:", len(image_urls), "image links, looking for more ...") time.sleep(30) return load_more_button = wd.find_element_by_css_selector(".mye4qd") if load_more_button: wd.execute_script("document.querySelector('.mye4qd').click();") # move the result startpoint further down results_start = len(thumbnail_results) return image_urls
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
from selenium import webdriver from webdriver_manager.chrome import ChromeDriverManager import time def fetch_image_urls(query:str, max_links_to_fetch:int, wd:webdriver, sleep_between_interactions:int=1): def scroll_to_end(wd): wd.execute_script("window.scrollTo(0, document.body.scrollHeight);") time.sleep(sleep_between_interactions) # build the google query search_url = "https://www.google.com/search?safe=off&site=&tbm=isch&source=hp&q={q}&oq={q}&gs_l=img" # load the page wd.get(search_url.format(q=query)) image_urls = set() image_count = 0 results_start = 0 while image_count < max_links_to_fetch: scroll_to_end(wd) # get all image thumbnail results thumbnail_results = wd.find_elements_by_css_selector("img.Q4LuWd") number_results = len(thumbnail_results) print(f"Found: {number_results} search results. Extracting links from {results_start}:{number_results}") for img in thumbnail_results[results_start:number_results]: # try to click every thumbnail such that we can get the real image behind it try: img.click() time.sleep(sleep_between_interactions) except Exception: continue # extract image urls actual_images = wd.find_elements_by_css_selector('img.n3VNCb') for actual_image in actual_images: if actual_image.get_attribute('src') and 'http' in actual_image.get_attribute('src'): image_urls.add(actual_image.get_attribute('src')) image_count = len(image_urls) if len(image_urls) >= max_links_to_fetch: print(f"Found: {len(image_urls)} image links, done!") break else: print("Found:", len(image_urls), "image links, looking for more ...") time.sleep(30) return load_more_button = wd.find_element_by_css_selector(".mye4qd") if load_more_button: wd.execute_script("document.querySelector('.mye4qd').click();") # move the result startpoint further down results_start = len(thumbnail_results) return image_urls wd = webdriver.Chrome(ChromeDriverManager().install()) image = fetch_image_urls('dog',5,wd) print(image)
Will output {'https://hips.hearstapps.com/hmg-prod.s3.amazonaws.com/images/dog-puppy-on-garden-royalty-free-image-1586966191.jpg', 'https://i.ytimg.com/vi/MPV2METPeJU/maxresdefault.jpg', 'https://cdn.mos.cms.futurecdn.net/QjuZKXnkLQgsYsL98uhL9X-1200-80.jpg', 'https://www.sciencemag.org/sites/default/files/styles/article_main_large/public/dogs_1280p_0.jpg?itok=cnRk0HYq', 'https://post.medicalnewstoday.com/wp-content/uploads/sites/3/2020/02/322868_1100-1100x628.jpg'}
This function will locate the text inside of a class for a web page
1 2
from bs4 import BeautifulSoup import requests
def finddiv(site,classofdiv): sauce = requests.get(site).text soup = BeautifulSoup(sauce, 'lxml') locatediv = soup.find('div', class_=classofdiv).text return locatediv print(finddiv('https://en.wikipedia.org/wiki/USS_Goldsborough_(DD-188)','mw-parser-output'))
Example Output:
USS Goldsborough, circa in 1920
HistoryUnited StatesName:GoldsboroughNamesake:Louis M. GoldsboroughBuilder:Newport News Shipbuilding & Dry Dock CompanyLaid down:8 June 1918Launched:20 November 1918Commissioned:26 January 1920Decommissioned:11 October 1945Struck:24 October 1945Fate:Sold for scrap, 21 November 1946
General characteristics Class and type:Clemson-class destroyerDisplacement:1,215 tonsLength:314 ft 5 in (95.83 m)Beam:31 ft 9 in (9.68 m)Draft:9 ft 4 in (2.84 m)Propulsion:
26,500 shp (19,800 kW)geared turbines,2 screwsSpeed:35 kn (65 km/h; 40 mph)Range:4,900 nmi (9,100 km; 5,600 mi) at 15 kn (28 km/h; 17 mph)Complement:101 officers and enlistedArmament:
4 × 4 in (102 mm)/50 cal. guns3 × 3 in (76 mm)/23 cal. guns12 × 21 inch (533 mm) torpedo tubes
USS Goldsborough (DD-188/AVP-18/AVD-5/APD-32) was a Clemson-class destroyer in the United States Navy during World War II. She was the second Navy ship named for Rear Admiral Louis M. Goldsborough (1805–1877). Entering service in 1920, the ship had a brief active life before being placed in reserve in 1922. Goldsborough was reactivated for World War II and was used as an aircraft tender, destroyer and high speed transport in both Atlantic and Pacific theaters. Following the war, the ship was sold for scrapping in 1946.
Contents
1 Construction and career
1.1 World War II1.2 Decommissioning
2 References3 External links
Construction and career[edit]Goldsborough was launched on 20 November 1918 by the Newport News Shipbuilding & Dry Dock Company, Newport News, Virginia, sponsored by Miss Lucetta Pennington Goldsborough, the daughter of Rear Admiral Goldsborough. The ship was commissioned at Norfolk, Virginia on 26 January 1920 with Commander Francis M. Robinson in command.Goldsborough joined Division 25, Squadron 3, U.S. Atlantic Fleet, departing Norfolk 25 February 1920 for training at Guantanamo Bay, Cuba, and returning to New York City on 1 May 1920 for maneuvers and tactics off the New England Coast. She stood out of Hampton Roads on 1 September 1920 on a practice cruise in the Gulf of Mexico, returning to Norfolk on 10 October for operations along the seaboard to New York until 5 January 1921 when she sailed to join the combined Battle Fleet off Cuba; thence she steamed through the Panama Canal to Callao, Peru, and back to Guantanamo Bay for further battle practice before return to Norfolk on 27 April. She entered Philadelphia Navy Yard 28 April for inactivation and decommissioned on 14 July 1922. She was redesignated AVP-18 on 15 November 1939. She was converted in the New York Navy Yard, recommissioned 1 July 1940; and redesignated AVD-5 on 2 August 1940.Goldsborough departed New York on 12 August 1940, to tend amphibious planes on Neutrality Patrol in waters ranging from Puerto Rico, Cuba, and the United States Virgin Islands, to Trinidad, British West Indies. She returned to Norfolk 23 January 1941 for repairs; conducted a cruise to the coast of Mexico and returned (3 March – 3 April), then served the Patrol Wing Support Force, Patrol Squadrons, U.S. Atlantic Fleet, at Naval Station Argentia, Newfoundland; Reykjavík, Iceland; and Gungnat Bay, Greenland. She arrived at Norfolk from Greenland on 13 October 1941 for repairs, and then proceeded to Seamour Bay, Galapagos Islands, arriving 23 December 1941. Here she tended amphibious patrol planes of Patrol Squadron 3, sometimes steaming down the coast of the Americas as far as Valparaíso, Chile, with time-out for service as a simulated target in Panama Bay.
World War II[edit]The destroyer transited the Panama Canal on 17 June 1942 and entered Trujillo Bay, Honduras, on 21 June with Commander Patrol Squadron 3 embarked to direct operations of the squadron on special patrols in conjunction with other naval units attempting to locate Axis submarine bases. After being contacted by patrol planes, a party from Goldsborough boarded Honduran merchant ship Laguna on 25 June and the Honduran merchant ship Racer the following day. Both were turned over to British authorities at Belize. On 3 July Goldsborough departed Puerta Castilla for Portland Bight, Jamaica. Here she tended aircraft on special patrols in the protection of convoys between Cuba and the Panama Canal. She arrived at the Charleston Navy Yard from Jamaica 2 October 1942 for repairs, followed by gunnery practice in the Chesapeake Bay.Goldsborough departed Norfolk 30 October 1942 to escort the seaplane tender Pocomoke to Panama and the seaplane tender Albemarle to aviation patrol bases at San Juan, Puerto Rico; Trinidad; and Bermuda, Florida. She returned to Norfolk on 30 November 1942 to spend the following year as escort for Albemarle while carrying men, aeronautical cargo, and aircraft of Fleet Air Wings of the U.S. Atlantic Fleet to Guantanamo Bay; Trinidad; Bermuda; San Juan; and Recife, Brazil. She returned to Norfolk on the last of these missions 5 September 1943. After patrolling with the USS Core antisubmarine warfare task group from 5 October-15 November 1943, Goldsborough was redesignated DD-188 on 1 December 1943.On 4 December 1943, Goldsborough sailed with the Core task group. Near midnight of 2 January 1944, she made visual contact with a surfaced U-boat off the Azores, fought through heavy seas in an attempt to ram amidships. She just missed the U-boat's stern as it slid under the sea. After two depth charge attacks, Goldsborough lost contact. She then screened Core to Norfolk 18 January and proceeded to New York Navy Yard for voyage repairs. Thereafter, she escorted Aucilla to Trinidad, returning to Norfolk as escort of Nitro then entered the Charleston Navy Yard on 21 February 1944 for conversion to a high-speed transport, and redesignation as APD-32, 7 March 1944.
Goldsborough in April 1944.Goldsborough departed Charleston on 10 April and reached Pearl Harbor, via the Panama Canal and San Diego on 9 May for amphibious assault training in Hanalei and Kawaihae Bay. She sailed on 29 May to rendezvous with a transport force proceeding via Ulithi to arrive off the invasion beaches of Saipan on 15 June 1944. An aerial bomb exploded 400 yards (370 m) to starboard as she assisted in repelling a raid of enemy dive bombers. The following day she landed the 2d Company, 1st Battalion, 2d Marines, just south of Charon Kanoa. During the next 5 weeks she escorted supply and troop convoys between the Marshall Islands and Saipan, taking time out for direct gunfire support of troops on Saipan the nights of 29 June and 7 July. She departed Saipan on 28 July to train Underwater Demolition Team 4 in Hawaiian waters, then joined a Beach Demolition Task Group that sailed from Manus, Admiralty Islands, on 12 October to destroy enemy facilities and installations in the vicinity of the proposed invasion beaches of eastern Leyte as well as on the entrance islands of Leyte Gulf. The afternoon of 18 October 1944 she performed shore bombardment operations into concealed enemy positions at Dulag, covering underwater demolition teams headed for the shore. Two 75 mm (3 in) shells straddled the high speed transport; and a third hit her number one stack, killing 2 and wounding 16 men. She screened the battleships and cruisers, carrying out a bombardment through the night of 19 October and supporting troops that launched the invasion the morning of 20 October 1944. She departed the following day to embark troops at Noemfoor, Schouten Islands, landing them on the beaches at Tolasa, Leyte, on 18 November 1944. She again arrived off Noemfoor on 19 December for transport of troops to Mios Woendi, Padiados Islands, and thence via Morotai with six merchant ships escorted into Leyte Gulf 6 January 1945. Her next assignment was patrolling the entrance of Lingayen Gulf. She dispatched a medical team to damaged destroyer escort Gilligan on 12 January, picked up two survivors, and then defended against a kamikaze which just missed the stern of Seusens before crashing into the sea. Goldsborough continued her patrol in the Gulf and off San Fabian until 18 January 1945.After voyage repairs at Ulithi, Goldsborough landed troops at Iwo Jima (3–6 March), thence via the Marianas to Tulagi harbor in the Solomons and back to Ulithi, where she joined transports bound for Okinawa. She arrived off Okinawa on 11 April, fought off aerial raids near Hagushi beaches the following day and rescued a Navy fighter pilot whose plane was damaged in aerial combat. She departed Okinawa on 14 April for repairs at Guam, returning on 15 May 1945 to patrol off Hagushi beaches until 31 May. Goldsborough was then routed via the Marianas, Marshalls, and Pearl Harbor to San Pedro, California, where she arrived 1 July 1945.
Decommissioning[edit]Redesignated again as destroyer (DD-188) on 10 July, she decommissioned there 11 October 1945. Her name was struck from the Navy List 24 October 1945 and she was sold for scrapping 21 November 1946 to Hugo Nuef Corporation, New York City.Goldsborough received five battle stars for service in World War II.
References[edit]This article incorporates text from the public domain Dictionary of American Naval Fighting Ships. The entry can be found here.External links[edit]
Wikimedia Commons has media related to USS Goldsborough (DD-188).
navsource.org: USS Goldsboroughhazegray.org: USS GoldsboroughvteClemson-class destroyers United States NavyClemsonDahlgrenGoldsboroughSemmesSatterleeMasonGrahamAbel P. UpshurHuntWelborn C. WoodGeorge E. BadgerBranchHerndonDallas / Alexander DallasChandlerSouthardHoveyLongBroomeAldenSmith ThompsonBarkerTracyBorieStewart / John D. EdwardsWhippleParrottEdsallMacLeishSimpsonBulmerMcCormickStewart / DD-224 (unnamed)PopePearyPillsburyFord / John D. FordTruxtunPaul JonesHatfieldBrooksGilmerFoxKaneHumphreysMcFarlandJames K. PauldingOvertonSturtevantChildsWilliamsonReuben JamesBainbridgeGoffBarryHopkinsLawrenceBelknapMcCookMcCallaKalk / RodgersIngram / Osmond IngramBancroftWellesAulickTurner / YW-56 (unnamed) / MooseheadGillisDelphyMcDermutLaubMcLanahanEdwardsAnthony / GreeneBallardShubrickBaileyThorntonMorrisTingeySwaseyMeadeSinclair / IX-37 (unnamed)McCawleyMoodyHenshawMeyerDoyenSharkeyTouceyBreckIsherwoodCaseLardnerPutnamWordenFlusserDaleStewart / ConverseStewart / ReidBillingsleyAusburn / Charles AusburnOsborneChaunceyFullerPercivalSwasey / John Francis BurnesFarragutSomersStoddertRenoFarquharThompsonKennedyPaul HamiltonWilliam JonesWoodburyBranch / S. P. LeeNicholasYoungZeilinYarboroughLa ValletteSloatWoodShirkKidderSelfridgeMarcusMervineChaseRobert SmithMullanyCoghlanPrestonLamsonBruceHullMacdonoughFarenholtSumnerCorryMelvinLitchfieldZaneWasmuthTreverPerryDecaturHulbertNoaWilliam B. PrestonPrebleSicardPruitt United States NavyUpshur (ex-Abel P. Upshur)Badger (ex-George E. Badger)HerndonHuntWood (ex-Welborn C. Wood)SemmesWorld War II operators Royal NavyPart of Town classBelmont (ex-Satterlee)Beverley (ex-Branch)Bradford (ex-McLanahan)Broadwater (ex-Mason)Broadway (ex-Hunt)Burnham (ex-Aulick)Burwell (ex-Laub)Buxton (ex-Edwards)Cameron (ex-Welles)Chesterfield (ex-Welborn C. Wood)Churchill (ex-Herndon)Clare (ex-Abel P. Upshur)Ramsey (ex-Meade)Reading (ex-Bailey)Ripley (ex-Shubrick)Rockingham (ex-Swasey)Sherwood (ex-Rodgers)Stanley (ex-McCalla) Royal Canadian NavyPart of Town classBuxtonSt. Croix (ex-McCook)St. Francis (ex-Bancroft) Imperial Japanese NavyPatrol Boat No. 102 (ex-Stewart) Soviet NavyDejatelny (ex-Churchill)
Preceded by: Wickes classFollowed by: Farragut class
List of destroyers of the United States Navy
vte"Flush-decker" destroyer high speed transport conversionsCaldwell-class conversionManleyWickes-class conversionsColhounGregoryLittleMcKeanStringhamTalbotWatersDentSchleyKiltyWardCrosbyTattnallRoperDickersonHerbertRathburneClemson-class conversionsBrooksGilmerHumphreysSandsKaneOvertonNoaMcFarlandXWilliamsonHulbertXBarryDecaturXClemsonGoldsboroughGeorge E. BadgerBelknapOsmond IngramGreene
XPlanned conversion to high speed transport cancelled
Preceded by: NoneFollowed by: Charles Lawrence class
List of United States Navy amphibious warfare ships
CODE:
def finddiv(site,classofdiv): sauce = requests.get(site).text soup = BeautifulSoup(sauce, 'lxml') locatediv = soup.find('div', class_=classofdiv).text return locatediv