Downloading raw text from webpage

Viewed 244

I'm looking to download all of the data from this webpage:

https://download.bls.gov/pub/time.series/la/la.data.64.County

If you open it, as you can see, a bunch of text data pops up, but the page freezes pretty quickly. The normal way I would do this is to :

1: ctrl+a
2: ctrl+c
3: ctrl+v into a text editor or excel
4: import that file into R

Since the page becomes unresponsive for me almost immediately, I am unable to do what I normally would.

Any ideas?

3 Answers

If you want to work with this data in R, you could use fread from data.table

library(data.table)
df <- fread('https://download.bls.gov/pub/time.series/la/la.data.64.County')
head(df)

#              series_id year period value footnote_codes
#1: LAUCN010010000000003 1990    M01   6.4               
#2: LAUCN010010000000003 1990    M02   6.6               
#3: LAUCN010010000000003 1990    M03   5.8               
#4: LAUCN010010000000003 1990    M04   6.6               
#5: LAUCN010010000000003 1990    M05   6.0               
#6: LAUCN010010000000003 1990    M06   7.0      

The data is very big but seems to import directly into R session.

You can use curl (linux)

curl https://download.bls.gov/pub/time.series/la/la.data.64.County -o data.txt

If you are on windows maybe one of this alternatives works for you.

  1. Inspect the current page

enter image description here

  1. Write document.getElementsByTagName("pre")[0].innerHTML;

enter image description here

3. Click on "copy"

enter image description here

And now paste it in notepad or something.

Related