How to extract text "lower" in a div - beautifulsoup

I am trying to extract all locations from a web page that are grouped into a large id=results div.
https://www.dynacast.com/en-gb/discover-dynacast/locations
My current code produces an empty list that I cannot interact with:
browser = mechanicalsoup.StatefulBrowser(soup_config={'features': 'lxml'}
locations_page = browser.page
locations_list = locations_page.find_all("div", id="location-list")
for locations_grid in locations_list:
grid = locations_grid.find_all_next("div", class_="grid-4")
print(grid)
Output = []
My aim is to extract all the text from this locations table (North America, Europe etc.) and the locations within the continents and append it to a list. Thank you in advance.

The page is dynamic so you won't get that html from a simple request. My suggestion is just get the data in json format from the api and can use pandas to normalize it:
import requests
import pandas as pd
url = 'https://www.dynacast.com/api/sitecore/Location/LocationsByServiceAjax'
payload = {
'serviceId': '',
'contextItemId': 'a9640857-ede5-47b3-a692-1606ee151d7c'}
jsonData = requests.get(url, params=payload).json()
df = pd.json_normalize(jsonData)
Output: 1st 5 of 15 rows below
print(df.head(5).to_string())
Id LocationName LocationAddress Phone Continent Country DirectionsLink CountryUrl Content Latitude Longitude SummaryContent SalesPhone ItemUrl IsFeatured
0 7ec388a8-adfa-4652-90b7-af1a089dfba1 Dynacast Tunisia Parc d'Activités Economiques de Bizerte\r\nSite de Menzel Bourguiba II BP 130\r\n7050 Menzel Bourguiba\r\nTunisie +216 72418363 Africa Tunisia https://www.google.com/maps?daddr=Parc+d%27Activit%C3%A9s+Economiques%2BMenzel+Bourguiba%2BBizerte%2BTunisia <p>Dynacast acquired Taurus Tunisia in 2016; it is located in Menzel Bourguiba, Bizerte, Tunisia just 30 minutes from the Tunis International Airport. This 1,900m<sup>2</sup> facility specializes in precision zinc die casting. Additional details about this location include:</p>\n<ul>\n<li>12 conventional zinc die casting machines ranging from 20T to 135T</li>\n<li>Production range from 0.5g to 0.9 kg</li>\n<li>Assembly operations </li>\n<li>In-house tool maintenance and repair</li>\n<li>Wide range of secondary operations and surface finishes including milling, thread cutting, sand blasting, and tumbling</li>\n</ul> 37.1450007 9.8045612 <p>Dynacast acquired Taurus Tunisia in 2016; it is located in Menzel Bourguiba, Bizerte, Tunisia. This 1,900m<sup>2</sup> facility specializes in precision zinc die casting.</p> /en/discover-dynacast/locations/dynacast-tunisia False
1 a7138364-2693-45b7-a886-4d526a325428 Sundaram Dynacast India No. 25 A/2, Sidco Industrial Park\nNorth Phase, Ambattur\nChennai, Tamil Nadu 600098 +91.44.2625.9169 Asia India https://www.google.com/maps?daddr=No.+25+A%2F2%2C+Sidco+Industrial+Park%2BChennai%2BTamil+Nadu%2BIndia <p>Sundaram Dynacast is a 68,000 square foot facility located in Ambattur, Chennai, India. The facility is the largest zinc high pressure hot chamber die caster in this area. Below are additional details about what is offered at this location:</p>\n<ul>\n<li>19 multi-slide proprietary zinc die casting machines ranging from 2.5 to 4.5 tons</li>\n<li>7 standard zinc die casting machines ranging from 25 to 63 tons</li>\n<li>8 aluminum die casting machine ranging from 125T to 350 tons</li>\n<li>Precision tool building with in-house capabilities</li>\n<li>Wide range of secondary operations including CNC machining, tapping, reaming, drilling, and assembly available through certified/dedicated partners</li>\n<li>Wide range of surface finishes are available in-house including tumbling, polishing, shot blasting, de-burring etc.. Plating, powder coating etc. are supported through our certified partners</li>\n</ul>\n<p /> 13.1094448 80.1666248 <p>Sundaram Dynacast is a 68,000 square foot facility located in Ambattur, Chennai, India. The facility is the largest zinc high pressure hot chamber die caster in this area. </p> /en/discover-dynacast/locations/sundaram-dynacast-india False
2 a2129999-b0d7-458b-bdd4-ae8a15dd4276 Dynacast Singapore 6 Second Chin Bee Road\r\nJurong, 618773 65.6268.7644 ext. 135 Asia Singapore <p>Dynacast Singapore focuses on multi-slide zinc, conventional zinc, aluminum, and magnesium die casting. Below are additional details about what is offered at the Singapore location:</p>\n<ul>\n<li>40 multi-slide proprietary zinc die casting machines ranging from 4 to 27 tons</li>\n<li>1 standard zinc die casting machines up to 125 tons</li>\n<li>4 aluminum die casting machines up to 135 tons</li>\n<li>1 multi-slide magnesium die casting machine up to 20 tons</li>\n<li>Precision tool building with in-house capabilities</li>\n<li>Wide range of secondary operations including CNC machining, tapping, reaming, and drilling available in house and through certified partners</li>\n<li>Design, prototyping, and modeling services</li>\n<li>Wide range of finishing surfaces available including tumbling, polishing, shot blasting and thermal de-burring</li>\n</ul>\n<p>www.dynacast.com.sg</p>\n<p><br /><strong>Dynacast Singapore works with OptiMIM, utilizing state-of-the-art metal injection molding technology to create high performing small precision metal components to almost any level of complexity and at virtually any volume.</strong></p> 1.332509 103.714238 <p>Dynacast Singapore focuses on multi-slide zinc, conventional zinc, aluminum, and magnesium die casting. </p> /en/discover-dynacast/locations/dynacast-singapore False
3 f2dd9429-d9d4-4028-b8ca-227972771980 Dynacast Tokyo (Regional Support Office) Azabu Green Terrace 5F\r\nMinamiazabu 3-20-1\r\nMinato-ku, Tokyo 106-0047 +03 6859-8512 Asia Japan <p>Dynacast Tokyo is a Regional Support Office that is strategically located to help with the demand for die casting components in the Asian market. Our sales team is available to help with any of your small precision component needs. </p>\n<p><a rel="noopener noreferrer" href="http://www.dynacast.jp" target="_blank">www.dynacast.jp</a></p> 35.649991 139.7307153 <p>Dynacast Tokyo is a sales office that is strategically located to help with the demand for die casting components in the Asian market. Our sales team is available to help with any of your small precision component needs. </p> /en/discover-dynacast/locations/dynacast-tokyo False
4 a4535e88-d1c3-4489-b351-cb75c4658f61 Dynacast Dongguan No. 88 Qiufu Road District\r\nFumin Industrial Park 2\r\nDalang, Dongguan, Guangdong 523778 86.769.8222.0638 (8801) Asia China https://www.google.com/maps?daddr=No.+88+Qiufu+Road+District%2BDalang%2C+Dongguan%2BGuangdong%2BChina <p>Dynacast Dongguan is a 14,000 square meter facility that is located in the heart of the Guangdong Province. The facility delivers high quality parts to the leading manufacturing hub in Southern China and focuses on zinc, aluminum, and magnesium die casting. Below are additional details about what is offered at the Dongguan location:</p>\n<ul>\n<li>28 zinc die casting machines ranging from 2 to 250 tons</li>\n<li>20 aluminum die casting machines ranging from 125 to 350 tons</li>\n<li>4 standard magnesium die casting machines ranging from 60 to 350 tons</li>\n<li>4 aluminum & magnesium die cast machines ranging from 60 to 350 tons </li>\n<li>2 standard plastic injection machines up to 100 tons</li>\n<li>Precision tool building with in-house capabilities</li>\n<li>Wide range of secondary operations including CNC machining, tapping, reaming, and drilling available in house and through certified partners</li>\n<li>Design, prototyping, and modeling services</li>\n<li>Wide range of finishing surfaces available including E-coating, electroless nickel plating, bright chrome, black chrome, spray painting, black anodising, micro-arc oxidation, copper nickle chrome, powder coating and passivation</li>\n</ul>\n<p>www.dynacast.cn</p>\n<p /> 22.9455755 113.9313944 <p>Dynacast Dongguan is a 14,000 square meter facility that is located in the heart of the Guangdong Province. The facility delivers high quality parts to the leading manufacturing hub in Southern China and focuses on zinc, aluminum, and magnesium die casting.</p> /en/discover-dynacast/locations/dynacast-dongguan False

Related

TraMineR for time-use data with over hundred different activities

I'm trying to analyse sequences with TraMineR
UKTUS records people activities for every 10 minutes defined by the dataset as act1_1, act1_2,...,act1_144 variables (144 x 10 minutes).
Each time step (act1_1, act1_2, act1_3) is defined by one of the following code:
-1 Not applicable
0 Unspecified personal care
110 Sleep
111 Sleep: In bed not asleep
120 Sleep: Sick in bed
210 Eating
300 Other personal care: Unspecified other personal care
310 Other personal care: Wash and dress
390 Other personal care: Other specified personal care
1000 Unspecified employment
1100 Main job: unspecified main job
1110 Main job: Working time in main job
1120 Main job: Coffee and other breaks in main job
1210 Second job: Working time in second job
1220 Second job: Coffee and other breaks in second job
1300 Activities related to employment: Unspecified activities related to employment
1310 Activities related to employment: Lunch break
1390 Activities related to employment: Other specified activities related to employment
1391 Activities related to employment: Activities related to job seeking
1399 Activities related to employment: Other unspecified activities related to employment
2000 Study: Unspecified study school or university
2100 Study: Unspecified activities related to school or university
2110 Study: Classes and lectures
2120 Study: Homework
2190 Study: other specified activities related to school or university
2210 Free time study
3000 Unspecified household and family care
3100 Unspecified food management
3110 Food preparation and baking
3130 Dish washing
3140 Preserving
3190 Other specified food management
3200 Unspecified household upkeep
3210 Cleaning dwelling
3220 Cleaning yard
3230 Heating and water
3240 Arranging household goods and materials
3250 Disposal of waste
3290 Other or unspecified household upkeep
3300 Unspecified making and care for textiles
3310 Laundry
3320 Ironing
3330 Handicraft and producing textiles
3390 Other specified making and care for textiles
3410 Gardening
3420 Tending domestic animals
3430 Caring for pets
3440 Walking the dog
3490 Other specified gardening and pet care
3500 Unspecified construction and repairs
3510 House construction and renovation
3520 Repairs of dwelling
3530 Making repairing and maintaining equipment
3531 Woodcraft metalcraft sculpture and pottery
3539 Other specified making repairing and maintaining equipment
3540 Vehicle maintenance
3590 Other specified construction and repairs
3600 Unspecified shopping and services
3610 Unspecified shopping
3611 Shopping mainly for food
3612 Shopping mainly for clothing
3613 Shopping mainly related to accommodation
3614 Shopping or browsing at car boot sales or antique fairs
3615 Window shopping or other shopping as leisure
3619 Other specified shopping
3620 Commercial and administrative services
3630 Personal services
3690 Other specified shopping and services
3710 Household management not using the internet
3713 Shopping for and ordering clothing via the internet
3720 Unspecified household management using the internet
3721 Shopping for and ordering unspecified goods and services via the internet
3722 Shopping for and ordering food via the internet
3724 Shopping for and ordering goods and services related to accommodation via the internet
3725 Shopping for and ordering mass media via the internet
3726 Shopping for and ordering entertainment via the internet
3727 Banking and bill paying via the internet
3729 Other specified household management using the internet
3800 Unspecified childcare
3810 Unspecified physical care & supervision of a child
3811 Feeding the child
3819 Other and unspecified physical care & supervision of a child
3820 Teaching the child
3830 Reading playing and talking with child
3840 Accompanying child
3890 Other or unspecified childcare
3910 Unspecified help to a non-dependent eg injured adult household member
3911 Physical care of a non-dependent e.g. injured adult household member
3914 Accompanying a non-dependent adult household member e.g. to hospital
3919 Other specified help to a non-dependent adult household member
3920 Unspecified help to a dependent adult household member
3921 Physical care of a dependent adult household member e.g. Alzheimic parent
3924 Accompanying a dependent adult household member e.g. Alzheimic
3929 Other specified help to a dependent adult household member
4000 Unspecified volunteer work and meetings
4100 Unspecified organisational work
4110 Work for an organisation
4120 Volunteer work through an organisation
4190 Other specified organisational work
4200 Unspecified informal help to other households
4210 Food management as help to other households
4220 Household upkeep as help to other households
4230 Gardening and pet care as help to other households
4240 Construction and repairs as help to other households
4250 Shopping and services as help to other households
4260 Help to other households in employment and farming
4270 Unspecified childcare as help to other households
4271 Physical care and supervision of child as help to other household
4272 Teaching non-coresident child
4273 Reading playing & talking to non-coresident child
4274 Accompanying non-coresident child
4275 Physical care and supervision of own child as help to other household
4277 Reading playing & talking to own non-coresident child
4278 Accompanying own non-coresident child
4279 Other specified childcare as help to other household
4280 Unspecified help to an adult of another household
4281 Physical care and supervision of an adult as help to another household
4282 Accompanying an adult as help to another household
4283 Other specified help to an adult member of another household
4289 Other specified informal help to another household
4290 Other specified informal help
4300 Unspecified participatory activities
4310 Meetings
4320 Religious activities
4390 Other specified participatory activities
5000 Unspecified social life and entertainment
5100 Unspecified social life
5110 Socialising with family
5120 Visiting and receiving visitors
5130 Celebrations
5140 Telephone conversation
5190 Other specified social life
5200 Unspecified entertainment and culture
5210 Cinema
5220 Unspecified theatre or concerts
5221 Plays musicals or pantomimes
5222 Opera operetta or light opera
5223 Concerts or other performances of classical music
5224 Live music other than classical concerts opera and musicals
5225 Dance performances
5229 Other specified theatre or concerts
5230 Art exhibitions and museums
5240 Unspecified library
5241 Borrowing books records audiotapes videotapes CDs VDs etc. from a library
5242 Reference to books and other library materials within a library
5243 Using internet in the library
5244 Using computers in the library other than internet use
5245 Reading newspapers in a library
5249 Other specified library activities
5250 Sports events
5290 Other unspecified entertainment and culture
5291 Visiting a historical site
5292 Visiting a wildlife site
5293 Visiting a botanical site
5294 Visiting a leisure park
5295 Visiting an urban park playground designated play area
5299 Other or unspecified entertainment or culture
5310 Resting - Time out
6000 Unspecified sports and outdoor activities
6100 Unspecified physical exercise
6110 Walking and hiking
6111 Taking a walk or hike that lasts at least miles or 1 hour
6119 Other walk or hike
6120 Jogging and running
6130 Biking skiing and skating
6131 Biking
6132 Skiing or skating
6140 Unspecified ball games
6141 Indoor pairs or doubles games
6142 Indoor team games
6143 Outdoor pairs or doubles games
6144 Outdoor team games
6149 Other specified ball games
6150 Gymnastics
6160 Fitness
6170 Unspecified water sports
6171 Swimming
6179 Other specified water sports
6190 Other specified physical exercise
6200 Unspecified productive exercise
6210 Hunting and fishing
6220 Picking berries mushroom and herbs
6290 Other specified productive exercise
6310 Unspecified sports related activities
6311 Activities related to sports
6312 Activities related to productive exercise
7000 Unspecified hobbies games and computing
7100 Unspecified arts
7110 Unspecified visual arts
7111 Painting drawing or other graphic arts
7112 Making videos taking photographs or related photographic activities
7119 Other specified visual arts
7120 Unspecified performing arts
7121 Singing or other musical activities
7129 Other specified performing arts
7130 Literary arts
7140 Other specified arts
7150 Unspecified hobbies
7160 Collecting
7170 Correspondence
7190 Other specified or unspecified arts and hobbies
7220 Computing - programming
7230 Unspecified information by computing
7231 Information searching on the internet
7239 Other specified information by computing
7240 Unspecified communication by computer
7241 Communication on the internet
7249 Other specified communication by computing
7250 Unspecified other computing
7251 Skype or other video call
7259 Other specified computing
7300 Unspecified games
7310 Solo games and play
7320 Unspecified games and play with others
7321 Billiards pool snooker or petanque
7322 Chess and bridge
7329 Other specified parlour games and play
7330 Computer games
7340 Gambling
7390 Other specified games
8000 Unspecified mass media
8100 Unspecified reading
8110 Reading periodicals
8120 Reading books
8190 Other specified reading
8210 Unspecified TV video or DVD watching
8211 Watching a film on TV
8212 Watching sport on TV
8219 Other specified TV watching
8220 Unspecified video watching
8221 Watching a film on video
8222 Watching sport on video
8229 Other specified video watching
8300 Unspecified listening to radio and music
8310 Unspecified radio listening
8311 Listening to music on the radio
8312 Listening to sport on the radio
8319 Other specified radio listening
8320 Listening to recordings
9000 Travel related to unspecified time use
9010 Travel related to personal business
9100 Travel to/from work
9110 Travel in the course of work
9120 Travel to work from home and back only
9130 Travel to work from a place other than home
9210 Travel related to education
9230 Travel escorting to/ from education
9310 Travel related to household care
9360 Travel related to shopping
9370 Travel related to services
9380 Travel escorting a child other than education
9390 Travel escorting an adult other than education
9400 Travel related to organisational work
9410 Travel related to voluntary work and meetings
9420 Travel related to informal help to other households
9430 Travel related to religious activities
9440 Travel related to participatory activities other than religious activities
9500 Travel to visit friends/relatives in their homes not respondents household
9510 Travel related to other social activities
9520 Travel related to entertainment and culture
9600 Travel related to other leisure
9610 Travel related to physical exercise
9620 Travel related to hunting & fishing
9630 Travel related to productive exercise other than hunting & fishing
9710 Travel related to gambling
9720 Travel related to hobbies other than gambling
9800 Travel related to changing locality
9810 Travel to holiday base
9820 Travel for day trip/just walk
9890 Other specified travel
9940 Punctuating activity
9941 Unknown: at home
9950 Filling in the time use diary
9960 No main activity no idea what it might be
9970 No main activity some idea what it might be
9980 Illegible activity
9990 Unspecified time use
9999 Queryable
I created a matrix in R with 129 columns and 16533 rows.
Activities <-uktus15_diary_wide[,c ("serial", "pnum","ddayw","DVAge", "dmonth", "dyear","WhenDiary","AfterDiaryDay","WhereStart","WhereEnd","RushedD","Ordinary","KindOfDay","Trip","enjm1","act1_1, "act1_2", "act1_3", "act1_4", "act1_5", "act1_6", "act1_7", "act1_8", "act1_9", "act1_10", "act1_11", "act1_12", "act1_13", "act1_14","act1_15", "act1_16", "act1_17", "act1_18", "act1_19", " "act1_21", "act1_22", "act1_23", "act1_24", "act1_25", "act1_26", "act1_27", "act1_28", "act1_29", "act1_30",
"act1_31", "act1_32", "act1_33", "act1_34", "act1_35", "act1_36", "act1_37", "act1_38", "act1_39", "act1_40",
"act1_41", "act1_42", "act1_43", "act1_44", "act1_45", "act1_46", "act1_47", "act1_48", "act1_49", "act1_50",
"act1_51", "act1_52", "act1_53", "act1_54", "act1_55", "act1_56", "act1_57", "act1_58", "act1_59", "act1_60",
"act1_61", "act1_62", "act1_63", "act1_64", "act1_65", "act1_66", "act1_67", "act1_68", "act1_69", "act1_70",
"act1_71", "act1_72", "act1_73", "act1_74", "act1_75", "act1_76", "act1_77", "act1_78", "act1_79", "act1_80",
"act1_81", "act1_82", "act1_83", "act1_84", "act1_85", "act1_86", "act1_87", "act1_88", "act1_89", "act1_90",
"act1_91", "act1_92", "act1_93", "act1_94", "act1_95", "act1_96", "act1_97", "act1_98", "act1_99", "act1_100",
"act1_101", "act1_102", "act1_103", "act1_104", "act1_105", "act1_106", "act1_107", "act1_108", "act1_109",
"act1_110", "act1_111", "act1_112", "act1_113", "act1_114")]
Example how the data looks like (I included just serial pnum act1_28 (activity between 8:30-8:40), act1_29 (activity between 8:40-8:50 and act1_30 (activity between 8:50-0:90 variables)
serial pnum act1_28 act1_29 act1_30
11011202 1 3110 3110 3110
11011202 2 3310 3310 7241
11011202 4 9210 9210 9210
My question is can we use TraMineR in this case to mine sequences? Can act1_1, act1_2...act1_144 be defined as a sequence? Can activity codes be used to define states?
Here is how you create the state sequence object from your example data
library(TraMineR)
dat <- matrix(c(11011202, 1, 3110, 3110, 3110,
11011202, 2, 3310, 3310, 7241,
11011202, 4, 9210, 9210, 9210),
nrow=3, ncol=5, byrow=TRUE)
names(dat) <- c("serial", "pnum", "act1_28", "act1_29", "act1_30")
## creating the state sequence object
s <- seqdef(dat[,3:5])
seqiplot(s)
Here, only four different states are involved.
However, the alphabet for your whole dataset is much larger. Several features of TraMineR will either not work or not produce useful outcomes when the alphabet contains too many states. E.g., chronograms or index plots with so many different states would be unreadable. Moreover, TraMineR automatically assigns colors to states only as long as the size of the alphabet does not exceed 12. Of course, many functions such as computing the complexity of the individual sequences (seqici), the sequence of cross-sectional distributions at the successive time intervals and their entropies (seqstatd), or even computing pairwise dissimilarities (seqdist) should work with large alphabets.
Nevertheless, to use TraMineR, I would strongly recommend that you consider to recoding your states so as to drastically reduce your alphabet to say less than 20 different states.

BS4 - grabbing information from something youve already parsed

hey this was kind of explained to me before but having trouble appying the same thing now to almost the same page...
page = 'http://www.imdb.com/genre/action/?ref_=gnr_mn_ac_mp'
table = soup.find_all("table", {"class": "results"})
for item in list(table):
for info in item.contents[1::2]:
info.a.extract()
link = info.a['href']
print(link)
name = info.text.strip()
print(name)
code above tries to capture the link to each page of each film contained in the a tag in the variable info... and the text in it has the name of each film but instead i get all the text. is there any way of just getting the name?
thanks guys in advance!!!
Just just need to pull the text from the anchor tag inside the td with the class title:
In [15]: from bs4 import BeautifulSoup
In [16]: import requests
In [17]: url = "http://www.imdb.com/genre/action/?ref_=gnr_mn_ac_mp"
In [18]: soup = BeautifulSoup(requests.get(url,"lxml").content)
In [19]: for td in soup.select("table.results td.title"):
....: print(td.a.text)
....:
X-Men: Apocalypse
Warcraft
Captain America: Civil War
The Do-Over
Teenage Mutant Ninja Turtles: Out of the Shadows
The Angry Birds Movie
The Nice Guys
Batman v Superman: Dawn of Justice
Suicide Squad
Deadpool
Gods of Egypt
Zootopia
13 Hours: The Secret Soldiers of Benghazi
Now You See Me 2
The Brothers Grimsby
Hardcore Henry
Monster Trucks
Independence Day: Resurgence
Star Trek Beyond
The Legend of Tarzan
Deepwater Horizon
X-Men: Days of Future Past
Star Wars: The Force Awakens
X-Men: First Class
The 5th Wave
Pretty much all the data you would want is inside the td with the title class:
So if you wanted the outline also all you need is the text from the span.outline:
In [24]: for td in soup.select("table.results td.title"):
....: print(td.a.text)
....: print(td.select_one("span.outline").text)
....:
X-Men: Apocalypse
With the emergence of the world's first mutant, Apocalypse, the X-Men must unite to defeat his extinction level plan.
Warcraft
The peaceful realm of Azeroth stands on the brink of war as its civilization faces a fearsome race of...
Captain America: Civil War
Political interference in the Avengers' activities causes a rift between former allies Captain America and Iron Man.
The Do-Over
Two down-on-their-luck guys decide to fake their own deaths and start over with new identities, only to find the people they're pretending to be are in even deeper trouble.
Teenage Mutant Ninja Turtles: Out of the Shadows
As Shredder joins forces with mad scientist Baxter Stockman and henchmen Bebop and Rocksteady to take over the world, the Turtles must confront an even greater nemesis: the notorious Krang.
The Angry Birds Movie
Find out why the birds are so angry. When an island populated by happy, flightless birds is visited by mysterious green piggies, it's up to three unlikely outcasts - Red, Chuck and Bomb - to figure out what the pigs are up to.
The Nice Guys
A mismatched pair of private eyes investigate the apparent suicide of a fading porn star in 1970s Los Angeles.
Batman v Superman: Dawn of Justice
Fearing that the actions of Superman are left unchecked, Batman takes on the Man of Steel, while the world wrestles with what kind of a hero it really needs.
Suicide Squad
A secret government agency recruits imprisoned supervillains to execute dangerous black ops missions in exchange for clemency.
Deadpool
A former Special Forces operative turned mercenary is subjected to a rogue experiment that leaves him with accelerated healing powers, adopting the alter ego Deadpool.
Gods of Egypt
Mortal hero Bek teams with the god Horus in an alliance against Set, the merciless god of darkness, who has usurped Egypt's throne, plunging the once peaceful and prosperous empire into chaos and conflict.
Zootopia
In a city of anthropomorphic animals, a rookie bunny cop and a cynical con artist fox must work together to uncover a conspiracy.
13 Hours: The Secret Soldiers of Benghazi
During an attack on a U.S. compound in Libya, a security team struggles to make sense out of the chaos.
Now You See Me 2
The Four Horsemen resurface and are forcibly recruited by a tech genius to pull off their most impossible heist yet.
The Brothers Grimsby
A new assignment forces a top spy to team up with his football hooligan brother.
Hardcore Henry
Henry is resurrected from death with no memory, and he must save his wife from a telekinetic warlord with a plan to bio-engineer soldiers.
Monster Trucks
Looking for any way to get away from the life and town he was born into, Tripp (Lucas Till), a high school senior...
Independence Day: Resurgence
Two decades after the first Independence Day invasion, Earth is faced with a new extra-Solar threat. But will mankind's new space defenses be enough?
Star Trek Beyond
The USS Enterprise crew explores the furthest reaches of uncharted space, where they encounter a mysterious new enemy who puts them and everything the Federation stands for to the test.
The Legend of Tarzan
Tarzan, having acclimated to life in London, is called back to his former home in the jungle to investigate the activities at a mining encampment.
Deepwater Horizon
A story set on the offshore drilling rig Deepwater Horizon, which exploded during April 2010 and created the worst oil spill in U.S. history.
X-Men: Days of Future Past
The X-Men send Wolverine to the past in a desperate effort to change history and prevent an event that results in doom for both humans and mutants.
Star Wars: The Force Awakens
Three decades after the defeat of the Galactic Empire, a new threat arises. The First Order attempts to rule the galaxy and only a ragtag group of heroes can stop them, along with the help of the Resistance.
X-Men: First Class
In 1962, the United States government enlists the help of Mutants with superhuman abilities to stop a malicious dictator who is determined to start World War III.
The 5th Wave
Four waves of increasingly deadly alien attacks have left most of Earth decimated. Cassie is on the run, desperately trying to save her younger brother.
For runtime td.select_one("span.runtime").text etc..
Just like how you got the link by doing
info.a['href']
You can also get the title of the movie by doing
info.a['title']
Hopefully this is what you're looking for!

How to get a brief description about a topic from wiki api?

I need to display a brief description about some topic. Like, when we search "India" on Google, it will show a brief description about India on the right side of the page, but that content is not an actual paragraph from wikipedia. does we get this content from wiki api?
https://www.mediawiki.org/wiki/Extension:TextExtracts#API, for example:
https://en.wikipedia.org/w/api.php?action=query&prop=extracts&exintro=1&explaintext=1&titles=India&continue=&format=json&formatversion=2 outputs
{
"batchcomplete": true,
"query": {
"pages": [
{
"pageid": 14533,
"ns": 0,
"title": "India",
"extract": "India (/ˈɪndiə/), officially the Republic of India (Bhārat Gaṇarājya), is a country in South Asia. It is the seventh-largest country by area, the second-most populous country with over 1.2 billion people, and the most populous democracy in the world. Bounded by the Indian Ocean on the south, the Arabian Sea on the south-west, and the Bay of Bengal on the south-east, it shares land borders with Pakistan to the west; China, Nepal, and Bhutan to the north-east; and Burma (Myanmar) and Bangladesh to the east. In the Indian Ocean, India is in the vicinity of Sri Lanka and the Maldives; in addition, India's Andaman and Nicobar Islands share a maritime border with Thailand and Indonesia.\nHome to the ancient Indus Valley Civilisation and a region of historic trade routes and vast empires, the Indian subcontinent was identified with its commercial and cultural wealth for much of its long history. Four religions—Hinduism, Buddhism, Jainism, and Sikhism—originated here, whereas Zoroastrianism and the Abrahamic religions of Judaism, Christianity, and Islam arrived in the 1st millennium CE and also helped shape the region's diverse culture. Gradually annexed by and brought under the administration of the British East India Company from the early 18th century and administered directly by the United Kingdom after the Indian Rebellion of 1857, India became an independent nation in 1947 after a struggle for independence that was marked by non-violent resistance led by Mahatma Gandhi.\nThe Indian economy is the world's seventh-largest by nominal GDP and third-largest by purchasing power parity (PPP). Following market-based economic reforms in 1991, India became one of the fastest-growing major economies; it is considered a newly industrialised country. However, it continues to face the challenges of poverty, corruption, malnutrition, inadequate public healthcare, and terrorism. A nuclear weapons state and a regional power, it has the third-largest standing army in the world and ranks ninth in military expenditure among nations. India is a federal constitutional republic governed under a parliamentary system consisting of 29 states and 7 union territories. India is a pluralistic, multilingual, and a multi-ethnic society. It is also home to a diversity of wildlife in a variety of protected habitats."
}
]
}
}

Selecting only a single row per id

I'd like to get back only one row per ID, even if there are multiple rows associated with an ID.
The scenario is that the data reflects a site selling land / properties, and that for each listing, there may be multiple images associated with each ID. I need only one.
Thank You.
As requested, sample data:
RowNumber ID UserID CountryID tbl_detailsID Name Description Price AddressLine1 AddressLine2 City State Zip AddressGPS Space Amenities Policies URL DateEntered DateExpires NumViews IsCompanyProperty EnforceMinStay IsOtherSite rate_Avg isFeatured DayPrice ImageURL Name check_in check_out currency bathroom_count pet unit_size elder handicap occupancy bedroom_count LinkURL smoking unit_size_Units property_Type children Minimum_stay Minimum_stay_Unit CountryName
2 247586 1 1 161398 Beautiful Oceanfront Home in Cambria California Located on the Central Coast of California 10 minutes from Hearst Castle.
Phone 1: Toll Free (800) 240-2277
Phone 2: (805) 927-0306 (California, USA)
direct email contact: debbie (#) maisonsdecambria.com
Leopold Cove" is a beautiful Oceanfront Home located on the Central Coast of California. It has fabulous ocean views and access to the water from a private stairway. The living area has large plate glass windows that feature 180 degree views of the Pacific Ocean. A comfortable platform style bed & a warm, cozy fireplace are also located in the living area so you can relax for hours, or even days, enjoying the beauty that surrounds you. There is a full kitchen & a separate bedroom with 2 twin beds. The property also has a picnic area & places to sit, perhaps with a good book & a glass of wine while you watch the sunset. If you are a nature lover, you will enjoy the otters, seals & birdlife that we are privileged to have so close to us. During the gray whale migration times, this is a p 2183 Sherwood Drive Cambria California 93428 35.544712|-121.095444 http://www.flipkey.com/cambria-vacation-rentals/p202618/ 2012-10-01 10:52:00 2012-10-15 10:52:00 0 0 0 703 5.0 0 NULL http://images1.flipkey.com/img/photos/302459/243298/large_302459-243298-007-1346943508.jpg Beautiful Oceanfront Home in Cambria California USD 1 Ask 0 Ask Ask 4 1 http://www.flipkey.com/cambria-vacation-rentals/p202618/ Ask House Ask 0 NULL United States
3 247586 1 1 161398 Beautiful Oceanfront Home in Cambria California Located on the Central Coast of California 10 minutes from Hearst Castle.
Phone 1: Toll Free (800) 240-2277
Phone 2: (805) 927-0306 (California, USA)
direct email contact: debbie (#) maisonsdecambria.com
Leopold Cove" is a beautiful Oceanfront Home located on the Central Coast of California. It has fabulous ocean views and access to the water from a private stairway. The living area has large plate glass windows that feature 180 degree views of the Pacific Ocean. A comfortable platform style bed & a warm, cozy fireplace are also located in the living area so you can relax for hours, or even days, enjoying the beauty that surrounds you. There is a full kitchen & a separate bedroom with 2 twin beds. The property also has a picnic area & places to sit, perhaps with a good book & a glass of wine while you watch the sunset. If you are a nature lover, you will enjoy the otters, seals & birdlife that we are privileged to have so close to us. During the gray whale migration times, this is a p 2183 Sherwood Drive Cambria California 93428 35.544712|-121.095444 http://www.flipkey.com/cambria-vacation-rentals/p202618/ 2012-10-01 10:52:00 2012-10-15 10:52:00 0 0 0 703 5.0 0 NULL http://images1.flipkey.com/img/photos/302459/243298/large_302459-243298-006-1346943508.jpg Beautiful Oceanfront Home in Cambria California USD 1 Ask 0 Ask Ask 4 1 http://www.flipkey.com/cambria-vacation-rentals/p202618/ Ask House Ask 0 NULL United States
4 247586 1 1 161398 Beautiful Oceanfront Home in Cambria California Located on the Central Coast of California 10 minutes from Hearst Castle.
Phone 1: Toll Free (800) 240-2277
Phone 2: (805) 927-0306 (California, USA)
direct email contact: debbie (#) maisonsdecambria.com
Leopold Cove" is a beautiful Oceanfront Home located on the Central Coast of California. It has fabulous ocean views and access to the water from a private stairway. The living area has large plate glass windows that feature 180 degree views of the Pacific Ocean. A comfortable platform style bed & a warm, cozy fireplace are also located in the living area so you can relax for hours, or even days, enjoying the beauty that surrounds you. There is a full kitchen & a separate bedroom with 2 twin beds. The property also has a picnic area & places to sit, perhaps with a good book & a glass of wine while you watch the sunset. If you are a nature lover, you will enjoy the otters, seals & birdlife that we are privileged to have so close to us. During the gray whale migration times, this is a p 2183 Sherwood Drive Cambria California 93428 35.544712|-121.095444 http://www.flipkey.com/cambria-vacation-rentals/p202618/ 2012-10-01 10:52:00 2012-10-15 10:52:00 0 0 0 703 5.0 0 NULL http://images1.flipkey.com/img/photos/302459/243298/large_302459-243298-005-1346943508.jpg Beautiful Oceanfront Home in Cambria California USD 1 Ask 0 Ask Ask 4 1 http://www.flipkey.com/cambria-vacation-rentals/p202618/ Ask House Ask 0 NULL United States
5 247586 1 1 161398 Beautiful Oceanfront Home in Cambria California Located on the Central Coast of California 10 minutes from Hearst Castle.
Phone 1: Toll Free (800) 240-2277
Phone 2: (805) 927-0306 (California, USA)
direct email contact: debbie (#) maisonsdecambria.com
Leopold Cove" is a beautiful Oceanfront Home located on the Central Coast of California. It has fabulous ocean views and access to the water from a private stairway. The living area has large plate glass windows that feature 180 degree views of the Pacific Ocean. A comfortable platform style bed & a warm, cozy fireplace are also located in the living area so you can relax for hours, or even days, enjoying the beauty that surrounds you. There is a full kitchen & a separate bedroom with 2 twin beds. The property also has a picnic area & places to sit, perhaps with a good book & a glass of wine while you watch the sunset. If you are a nature lover, you will enjoy the otters, seals & birdlife that we are privileged to have so close to us. During the gray whale migration times, this is a p 2183 Sherwood Drive Cambria California 93428 35.544712|-121.095444 http://www.flipkey.com/cambria-vacation-rentals/p202618/ 2012-10-01 10:52:00 2012-10-15 10:52:00 0 0 0 703 5.0 0 NULL http://images1.flipkey.com/img/photos/302459/243298/large_302459-243298-004-1346943508.jpg Beautiful Oceanfront Home in Cambria California USD 1 Ask 0 Ask Ask 4 1 http://www.flipkey.com/cambria-vacation-rentals/p202618/ Ask House Ask 0 NULL United States
6 247586 1 1 161398 Beautiful Oceanfront Home in Cambria California Located on the Central Coast of California 10 minutes from Hearst Castle.
Phone 1: Toll Free (800) 240-2277
Phone 2: (805) 927-0306 (California, USA)
direct email contact: debbie (#) maisonsdecambria.com
Leopold Cove" is a beautiful Oceanfront Home located on the Central Coast of California. It has fabulous ocean views and access to the water from a private stairway. The living area has large plate glass windows that feature 180 degree views of the Pacific Ocean. A comfortable platform style bed & a warm, cozy fireplace are also located in the living area so you can relax for hours, or even days, enjoying the beauty that surrounds you. There is a full kitchen & a separate bedroom with 2 twin beds. The property also has a picnic area & places to sit, perhaps with a good book & a glass of wine while you watch the sunset. If you are a nature lover, you will enjoy the otters, seals & birdlife that we are privileged to have so close to us. During the gray whale migration times, this is a p 2183 Sherwood Drive Cambria California 93428 35.544712|-121.095444 http://www.flipkey.com/cambria-vacation-rentals/p202618/ 2012-10-01 10:52:00 2012-10-15 10:52:00 0 0 0 703 5.0 0 NULL http://images1.flipkey.com/img/photos/302459/243298/large_302459-243298-003-1346943508.jpg Beautiful Oceanfront Home in Cambria California USD 1 Ask 0 Ask Ask 4 1 http://www.flipkey.com/cambria-vacation-rentals/p202618/ Ask House Ask 0 NULL United States
7 247586 1 1 161398 Beautiful Oceanfront Home in Cambria California Located on the Central Coast of California 10 minutes from Hearst Castle.
Phone 1: Toll Free (800) 240-2277
Phone 2: (805) 927-0306 (California, USA)
direct email contact: debbie (#) maisonsdecambria.com
Leopold Cove" is a beautiful Oceanfront Home located on the Central Coast of California. It has fabulous ocean views and access to the water from a private stairway. The living area has large plate glass windows that feature 180 degree views of the Pacific Ocean. A comfortable platform style bed & a warm, cozy fireplace are also located in the living area so you can relax for hours, or even days, enjoying the beauty that surrounds you. There is a full kitchen & a separate bedroom with 2 twin beds. The property also has a picnic area & places to sit, perhaps with a good book & a glass of wine while you watch the sunset. If you are a nature lover, you will enjoy the otters, seals & birdlife that we are privileged to have so close to us. During the gray whale migration times, this is a p 2183 Sherwood Drive Cambria California 93428 35.544712|-121.095444 http://www.flipkey.com/cambria-vacation-rentals/p202618/ 2012-10-01 10:52:00 2012-10-15 10:52:00 0 0 0 703 5.0 0 NULL http://images1.flipkey.com/img/photos/302459/243298/large_302459-243298-002-1346943508.jpg Beautiful Oceanfront Home in Cambria California USD 1 Ask 0 Ask Ask 4 1 http://www.flipkey.com/cambria-vacation-rentals/p202618/ Ask House Ask 0 NULL United States
8 247586 1 1 161398 Beautiful Oceanfront Home in Cambria California Located on the Central Coast of California 10 minutes from Hearst Castle.
Phone 1: Toll Free (800) 240-2277
Phone 2: (805) 927-0306 (California, USA)
direct email contact: debbie (#) maisonsdecambria.com
Leopold Cove" is a beautiful Oceanfront Home located on the Central Coast of California. It has fabulous ocean views and access to the water from a private stairway. The living area has large plate glass windows that feature 180 degree views of the Pacific Ocean. A comfortable platform style bed & a warm, cozy fireplace are also located in the living area so you can relax for hours, or even days, enjoying the beauty that surrounds you. There is a full kitchen & a separate bedroom with 2 twin beds. The property also has a picnic area & places to sit, perhaps with a good book & a glass of wine while you watch the sunset. If you are a nature lover, you will enjoy the otters, seals & birdlife that we are privileged to have so close to us. During the gray whale migration times, this is a p 2183 Sherwood Drive Cambria California 93428 35.544712|-121.095444 http://www.flipkey.com/cambria-vacation-rentals/p202618/ 2012-10-01 10:52:00 2012-10-15 10:52:00 0 0 0 703 5.0 0 NULL http://images1.flipkey.com/img/photos/302459/243298/large_302459-243298-001-1346943508.jpg Beautiful Oceanfront Home in Cambria California USD 1 Ask 0 Ask Ask 4 1 http://www.flipkey.com/cambria-vacation-rentals/p202618/ Ask House Ask 0 NULL United States
And the Omni-query I that I am constructing to replace a few hundred lines of temp tables:
SELECT DISTINCT ROW_NUMBER() OVER(ORDER BY tbl_Properties.ID DESC) AS [RowNumber], tbl_Properties.ID, tbl_Properties.UserID, tbl_Properties.CountryID, tbl_Properties.tbl_detailsID, tbl_Properties.Name,
tbl_Properties.[Description], tbl_Properties.Price, tbl_Properties.AddressLine1, tbl_Properties.AddressLine2, tbl_Properties.City, tbl_Properties.[State], tbl_Properties.Zip, tbl_Properties.AddressGPS,
tbl_Properties.[Space],
tbl_Properties.Amenities,
tbl_Properties.Policies,
tbl_Properties.URL,
tbl_Properties.DateEntered,
tbl_Properties.DateExpires,
tbl_Properties.NumViews,
tbl_Properties.IsCompanyProperty,
tbl_Properties.EnforceMinStay,
tbl_Properties.IsOtherSite,
tbl_Properties.rate_Avg,
tbl_Properties.isFeatured,
tbl_Properties.DayPrice,
tbl_Images.ImageURL,
tbl_Details.Name,
tbl_Details.check_in,
tbl_Details.check_out,
tbl_Details.currency,
tbl_Details.bathroom_count,
tbl_Details.pet,
tbl_Details.unit_size,
tbl_Details.elder,
tbl_Details.handicap,
tbl_Details.occupancy,
tbl_Details.bedroom_count,
tbl_Details.url As [LinkURL],
tbl_Details.smoking,
tbl_Details.unit_size_Units,
tbl_Details.property_Type,
tbl_Details.children,
tbl_Details.Minimum_stay,
tbl_Details.Minimum_stay_Unit,
tbl_Countries.Name As [CountryName]
FROM [tbl_Details]
INNER JOIN [tbl_Properties] ON [tbl_Details].[detailsID] = [tbl_Properties].[tbl_detailsID]
INNER JOIN [tbl_Images] ON [tbl_Images].PropertyID = [tbl_Properties].ID
INNER JOIN [tbl_Countries] ON [tbl_Countries].ID = [tbl_Properties].CountryID
The query itself is, of course, not finished yet.
If your SQLServer version supports row_number() OVER (2008,2012 support)
select * from
(select t.*,
row_number() over (partition by id order by id) as rownumber from t
) t1
where t1.rownumber=1
Here is the SQLFiddle example
Since there's no sample data you'll need to bend this response to suit your needs
select
Listings.*, SingleImage.Column1, SingleImage.Column2
from Listings
cross apply (
select top 1 *
from Images
where Listings.ListingID = Images.ListingID
) SingleImage
That needs SQL 2005 or newer (for the "cross apply" to work)
There are ways to make it work in SQL 2000 too but they're not as efficient
try this:
SELECT TOP 1 * FROM
imagestable
WHERE imagestable.landID = <theID>
This will return the first image in the table that belongs to the property.
You can INNER JOIN this query with your property table if you want to return all property info as a single record.
In SQL Server 2005+ you can use this
use tempdb
go
create table tbl (id int, s varchar(50))
insert into tbl values (1,'qwe'),(1,'asd'), (1,'qwff'),(2,'ert'),(2,'ykf'),(3,'')
;with cte
AS
(
SELECT id,s, ROW_NUMBER() OVER (PARTITION BY id ORDER BY s ) n
FROM tbl
)
SELECT id,s
FROM CTE
WHERE n=1
drop table tbl

Does the Luhn algorithm work for all mainstream credit cards? (Discover, Visa, Mastercard, Amex)

Reference: Luhn Algorithm
The Luhn Algorithm is a great way to quickly verify that the user typed their CC # in correctly.
However, I am concerned that there may be a subset of mainstream credit cards that do not use Luhn-Algorithm-friendly numbers.
I do have logging in place in our application to detect a pattern in all Luhn-Algorithm-rejections, but I'd rather know definitively.
Almost.
China UnionPay and one kind of Diners Club card (enRoute) do not use Luhn validation. (LazyOne’s answer is wrong about Diners Club.)
Nearly everyone else does.
Citing Wikipedia's 'Bank card' page:
Don't validate at all:
Diners Club enRoute
China UnionPay
Validate with Luhn 2:
American Express
Bankcard
Diners Club Carte Blanche
Diners Club International
Diners Club United States & Canada
Discover Card
InstaPayment
JCB
Laser
Maestro
Dankort
MasterCard
Solo
Switch
Visa
Visa Electron
Yes -- it works for all mainstream card types.
I have a custom PHP class to handle card data that was compiled from various "validate card number" and alike functions from few programming languages + information from Wikipedia & some Payment Processing systems. It successfully validates test card numbers (every payment system has few of such numbers) for these card types:
VISA debit / credit
VISA Electron
VISA Delta
MasterCard
AMEX
Maestro
Switch
Solo
Diners Club
Discover
JCB
The LUN check works on most credit cards. It is a modulus 10 check digit system to guarantee that the card number has been accurately read/recorded (mag stripe, virtual terminal or manual entry in the old days of the manual card imprinter).
Back in the days of manual data entry, these check systems were used to make sure that keys like UPS's pickup book numbering system were accurately entered (modulus 7 check digit).
It is even used in barcoding systems like code 128 which needs a modulus 103 digit added to the encoded data string to verify that the code was read right.