diff --git a/slack-pixiv/commands/illust.rb b/slack-pixiv/commands/illust.rb index 641f657..862619b 100644 --- a/slack-pixiv/commands/illust.rb +++ b/slack-pixiv/commands/illust.rb @@ -23,8 +23,16 @@ module SlackMathbot ios_url = "pixiv://illusts/" + pixiv_url[/\d+/] puts ios_url + # Scrape profile link + profile = agent.get(pixiv_url).at("div.userdata > h2.name > a").attributes['href'].to_s + puts profile + + # Create iOS Members URL + ios_mem_url = "pixiv://users/" + profile[/\d+/] + puts ios_mem_url + # Scrape page title - title = Mechanize.new.get(pixiv_url).title + title = agent.get(pixiv_url).title puts title # Scrape image @@ -37,7 +45,7 @@ module SlackMathbot attachments: [ { fallback: title + " - " + pixiv_url, - text: "<" + ios_url + "|Open in App>", + text: "<" + ios_url + "|Open Image in App> | <" + ios_mem_url + "|Open Profile in App>", title: title, title_link: pixiv_url, image_url: image_url, diff --git a/slack-pixiv/commands/member.rb b/slack-pixiv/commands/member.rb index 428053c..bfbbc5e 100644 --- a/slack-pixiv/commands/member.rb +++ b/slack-pixiv/commands/member.rb @@ -8,22 +8,21 @@ module SlackMathbot agent = Mechanize.new pixiv_url = "http://www.pixiv.net/member.php" + _match[:url][0..-2] - puts pixiv_url.split("?id=")[-1] + # Scrape page title - title = Mechanize.new.get(pixiv_url).title + title = agent.get(pixiv_url).title puts title # Scrape username - username = Mechanize.new.get(pixiv_url).at(".name").text + username = agent.get(pixiv_url).at(".name").text puts username # Scrape profile comment - profile_comment = Mechanize.new.get(pixiv_url).at(".profile-comment").text.split("br { display : none;}")[-1] + profile_comment = agent.get(pixiv_url).at(".profile-comment").text.split("br { display : none;}")[-1] puts profile_comment # Scrape works count - #works = Mechanize.new.get(pixiv_url).at(".count") works = agent.get(pixiv_url).links_with(:class => /int/) puts works