1
0
Fork 0
scrape-and-text/README.md

34 lines
538 B
Markdown
Raw Permalink Normal View History

2016-11-08 22:40:43 -05:00
# Ruby User Group, 08 Nov 2016
Text alerting on a website content change
* web request
2016-11-08 22:42:53 -05:00
```
2016-11-08 22:40:43 -05:00
require 'net/http'
uri = URI('https://github.com/chrisvfritz')
content = Net::HTTP.get(uri)
2016-11-08 22:42:53 -05:00
```
2016-11-08 22:40:43 -05:00
* parse content
2016-11-08 22:42:53 -05:00
```
2016-11-08 22:40:43 -05:00
require 'nokogiri'
parsed = Nokogiri::HTML(content)
2016-11-08 22:42:53 -05:00
chris_face = parse.css('.avatar').attr('src').value
```
2016-11-08 22:40:43 -05:00
* ??? (process)
* send text
2016-11-08 22:42:53 -05:00
```
2016-11-08 22:40:43 -05:00
require 'twilio-ruby'
2016-11-08 22:42:53 -05:00
client = Twilio::REST::Client.new(account_sid, auth_token)
2016-11-08 22:40:43 -05:00
client.messages.create(
2016-11-08 22:42:53 -05:00
from: from_number,
to: notification_number,
2016-11-08 22:40:43 -05:00
body: 'Repos changed'
)
2016-11-08 22:42:53 -05:00
```