Skip to content

Instantly share code, notes, and snippets.

@inglesp
Last active June 30, 2020 10:48
Show Gist options
  • Save inglesp/758731fbcf0af049a2af5c9bbfd74903 to your computer and use it in GitHub Desktop.
Save inglesp/758731fbcf0af049a2af5c9bbfd74903 to your computer and use it in GitHub Desktop.
Scraper and data for 2020 CCG changes
old_code old_name new_name new_code
00D Durham Dales, Easington and Sedgfield CCG NHS County Durham CCG 84H
00J North Durham CCG NHS County Durham CCG 84H
00C Darlington CCG NHS Tees Valley CCG 16C
00K Hartlepool and Stockton-on-Tees CCG NHS Tees Valley CCG 16C
00M South Tees CCG NHS Tees Valley CCG 16C
03D Hambleton, Richmondshire and Whitby CCG NHS North Yorkshire CCG 42D
03M Scarborough and Ryedale CCG NHS North Yorkshire CCG 42D
03E Harrogate and Rural District CCG NHS North Yorkshire CCG 42D
02N Airedale, Wharfedale and Craven CCG NHS Bradford District and Craven CCG 36J
02W Bradford City CCG NHS Bradford District and Craven CCG 36J
02R Bradford Districts CCG NHS Bradford District and Craven CCG 36J
01C Eastern Cheshire CCG NHS Cheshire CCG 27D
01R South Cheshire CCG NHS Cheshire CCG 27D
02D Vale Royal CCG NHS Cheshire CCG 27D
02F West Cheshire CCG NHS Cheshire CCG 27D
05F Herefordshire CCG NHS Herefordshire and Worcestershire CCG 18C
05J Redditch and Bromsgrove CCG NHS Herefordshire and Worcestershire CCG 18C
05T South Worcestershire CCG NHS Herefordshire and Worcestershire CCG 18C
06D Wyre Forest CCG NHS Herefordshire and Worcestershire CCG 18C
03V Corby CCG NHS Northamptonshire CCG 78H
04G Nene CCG NHS Northamptonshire CCG 78H
04E Mansfield and Ashfield CCG NHS Nottingham and Nottinghamshire CCG 52R
04H Newark and Sherwood CCG NHS Nottingham and Nottinghamshire CCG 52R
04K Nottingham City CCG NHS Nottingham and Nottinghamshire CCG 52R
04L Nottingham North and East CCG NHS Nottingham and Nottinghamshire CCG 52R
04M Nottingham West CCG NHS Nottingham and Nottinghamshire CCG 52R
04N Rushcliffe CCG NHS Nottingham and Nottinghamshire CCG 52R
03T Lincolnshire East CCG NHS Lincolnshire CCG 71E
04D Lincolnshire West CCG NHS Lincolnshire CCG 71E
99D South Lincolnshire CCG NHS Lincolnshire CCG 71E
04Q South West Lincolnshire CCG NHS Lincolnshire CCG 71E
06M Great Yarmouth and Waveney CCG NHS Norfolk & Waveney CCG 26A
06V North Norfolk CCG NHS Norfolk & Waveney CCG 26A
07J West Norfolk NHS Norfolk & Waveney CCG 26A
06Y South Norfolk CCG NHS Norfolk & Waveney CCG 26A
06W Norwich CCG NHS Norfolk & Waveney CCG 26A
07N NHS Bexley CCG NHS South East London CCG 72Q
07Q NHS Bromley CCG NHS South East London CCG 72Q
08A NHS Greenwich CCG NHS South East London CCG 72Q
08K NHS Lambeth CCG NHS South East London CCG 72Q
08L NHS Lewisham CCG NHS South East London CCG 72Q
08Q NHS Southwark CCG NHS South East London CCG 72Q
07V NHS Croydon CCG NHS South West London CCG 36L
08J NHS Kingston CCG NHS South West London CCG 36L
08P NHS Richmond CCG NHS South West London CCG 36L
08R NHS Merton CCG NHS South West London CCG 36L
08T NHS Sutton CCG NHS South West London CCG 36L
08X NHS Wandsworth CCG NHS South West London CCG 36L
07M NHS Barnet CCG NHS North Central London CCG 93C
07R NHS Camden CCG NHS North Central London CCG 93C
07X NHS Enfield CCG NHS North Central London CCG 93C
08D NHS Haringey CCG NHS North Central London CCG 93C
08H NHS Islington CCG NHS North Central London CCG 93C
09C Ashford CCG NHS Kent and Medway CCG 91Q
09E Canterbury and Coastal CCG NHS Kent and Medway CCG 91Q
09J Dartford, Gravesham and Swanley CCG NHS Kent and Medway CCG 91Q
09W Medway CCG NHS Kent and Medway CCG 91Q
10A South Kent Coast CCG NHS Kent and Medway CCG 91Q
10D Swale CCG NHS Kent and Medway CCG 91Q
10E Thanet CCG NHS Kent and Medway CCG 91Q
99J West Kent CCG NHS Kent and Medway CCG 91Q
09N Guildford and Waverley CCG NHS Surrey Heartlands CCG 92A
09Y North West Surrey CCG NHS Surrey Heartlands CCG 92A
99H Surrey Downs CCG NHS Surrey Heartlands CCG 92A
09L East Surrey NHS Surrey Heartlands CCG 92A
09G Coastal West Sussex CCG NHS West Sussex CCG 70F
09H Crawley CCG NHS West Sussex CCG 70F
09X Horsham and Mid Sussex CCG NHS West Sussex CCG 70F
09P Hastings and Rother CCG NHS East Sussex CCG 97R
99K High Weald Lewes Havens CCG NHS East Sussex CCG 97R
09F Eastbourne Hailsham and Seaford CCG NHS East Sussex CCG 97R
11E Bath and North East Somerset CCG NHS Bath and North East Somerset, Swindon and Wiltshire CCG 92G
12D Swindon CCG NHS Bath and North East Somerset, Swindon and Wiltshire CCG 92G
99N Wiltshire CCG NHS Bath and North East Somerset, Swindon and Wiltshire CCG 92G
import csv
import requests
from bs4 import BeautifulSoup
url = "https://digital.nhs.uk/services/organisation-data-service/change-summary---stp-reconfiguration"
rsp = requests.get(url)
doc = BeautifulSoup(rsp.text, "html.parser")
with open("ccg-changes.csv", "w") as f:
writer = csv.writer(f)
writer.writerow(["old_code", "old_name", "new_name", "new_code"])
for th in doc.find_all("th", text="Legacy (closing) CCG code"):
table = th.find_parent("table")
for tr in table.find("tbody").find_all("tr"):
writer.writerow([td.text.strip() for td in tr.find_all("td")])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment