auto_check_manuscript_status

论文投出去一个多月了,想及时得知审稿情况,每次登陆检查有很麻烦,因此打算用脚本实现自动检查功能。

Headless browser

Use selenium with chromedriver to achieve a headless browser.

check-manuscript-status.pycheck-manuscript-status.py
1
2
3
4
5
6
7
8
9
from selenium import webdriver
chromedriver = '/Applications/Google Chrome.app/Contents/MacOS/chromedriver'
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--disable-gpu')
chrome_login=webdriver.Chrome(chromedriver, chrome_options=chrome_options)
chrome_login.get('https://mc.manuscriptcentral.com/jbhi-embs')

Get manuscript status

  • First analyze the login page to locate where to fulfill the user name and password.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<!-- LOG IN AREA-->
...
<div>
<h4 class="help-block">User ID</h4>
<input type="text" class="input-block-level" name="USERID" id="USERID" hidefocus="true" style="outline: none;">
</div>
<!-- Password-->
<div>
<h4 class="help-block h4special">Password</h4>
<div class="input-append input-group input-block-level">
<div class="input-append input-group input-block-level"><input class="passwordField" type="password" name="PASSWORD" id="PASSWORD" hidefocus="true" style="outline: none;"><input type="text" class="passwordField" style="display: none;"><span tabindex="100" title="Show/hide password" class="add-on input-group-addon" style="cursor: pointer;"><i class="icon-eye-open glyphicon glyphicon-eye-open"></i></span></div>
</div>
<span>
<a href="javascript:setNextPage(&#39;RESET_PASSWORD&#39;);" hidefocus="true" style="outline: none;">Reset Password</a>
</span>
</div>
<hr class="hrthin">
<!-- Button -->
<div>
<a id="logInButton" class="btn btn-primary" hidefocus="true" style="outline: none;">
Log In
</a>
...
check-manuscript-status.pycheck-manuscript-status.py
1
2
3
4
5
6
# Login
chrome_login.find_element_by_id('USERID').clear()
chrome_login.find_element_by_id('USERID').send_keys(u'username')
chrome_login.find_element_by_id('PASSWORD').clear()
chrome_login.find_element_by_id('PASSWORD').send_keys(u'password')
chrome_login.find_element_by_id('logInButton').click()
  • Then select the Author page as the current page.
1
2
3
4
5
6
7
8
9
<!--Top Level Nav -->
...
<li class="nav-link ">
<a href="javascript:setDataAndNextPage(&#39;XIK_CUR_ROLE_ID&#39;,&#39;xik_CEvy3hq64RUUemtdi9mg2oQPSBCMD1B7sN94hApF4358&#39;,&#39;AUTHOR_VIEW_MANUSCRIPTS&#39;)" hidefocus="true" style="outline: none;">
<i class="fa fa-pencil"></i> Author
</a>
</li>
...
<!--Top Level Nav End -->
check-manuscript-status.pycheck-manuscript-status.py
1
chrome_login.find_elements_by_class_name('nav-link ')[6].click()
  • Then locate the status table and get the table contents.
1
2
3
4
<!-- common jspf for the most of the author's queues -->
<div class="content-inner-div">
...
</div>
check-manuscript-status.pycheck-manuscript-status.py
1
table = chrome_login.find_element_by_class_name('content-inner-div').text.split('\n')
  • Finally analyze the table contents to get the manuscript status.

Notify if status changed

Use osascript -e to send notification under Mac OSX.

check-manuscript-status.pycheck-manuscript-status.py
1
os.system("osascript -e 'display notification \"" + s + "\" with title \"" + "Manuscript Status" + "\" sound name \"Submarine\"'")

Use crontab to frequently doing this check, add a crontab task by execute crontab -e and set

1
1 * * * * /usr/bin/python /Users/username/Desktop/check-manuscript-status.py